309 lines
18 KiB
PHP
309 lines
18 KiB
PHP
|
<?php
|
||
|
// error_reporting(0);
|
||
|
// include "../includes/config/config.php";
|
||
|
// include "functions.php";
|
||
|
// include 'log_entry.php';
|
||
|
// $response = array();
|
||
|
// if($conn) {
|
||
|
// $sql = "SELECT * from patient_master where id = '".$_REQUEST['id']."'";
|
||
|
// error_log("errr".$sql);
|
||
|
// $result = mysqli_query($conn,$sql);
|
||
|
// if($result) {
|
||
|
// $i=0;
|
||
|
// while($row = mysqli_fetch_assoc($result)){
|
||
|
// $dateOfBirth = $row['dob'];
|
||
|
// $today = date("Y-m-d");
|
||
|
// $diff = date_diff(date_create($dateOfBirth), date_create($today));
|
||
|
// if( $row['gender'] == 'M' ) { $gender = 'MALE'; } else if ($row['gender'] == 'F') { $gender = 'FEMALE'; } else { $gender = 'Other'; }
|
||
|
// $response[$i]['id'] = $row['id'];
|
||
|
// $response[$i]['age'] = $diff->format('%y');
|
||
|
// $response[$i]['emp_code'] = $row['emp_code'];
|
||
|
// $response[$i]['patient_name'] = $row['patient_name'];
|
||
|
// $response[$i]['father_name'] = $row['father_name'];
|
||
|
// $response[$i]['dob'] = date_format( date_create($row['dob']) ,"d-m-Y");
|
||
|
// $response[$i]['gender'] = $gender;
|
||
|
// $response[$i]['aadhar_no'] = $row['aadhar_no'];
|
||
|
// $response[$i]['village'] = $row['village'];
|
||
|
// $response[$i]['post'] = $row['post'];
|
||
|
// $response[$i]['ps'] = $row['ps'];
|
||
|
// $response[$i]['tehsil'] = $row['tehsil'];
|
||
|
// $response[$i]['district'] = $row['district'];
|
||
|
// $response[$i]['primary_contact_no'] = $row['primary_contact_no'];
|
||
|
// $response[$i]['state'] = $row['state'];
|
||
|
// $response[$i]['pin_code'] = $row['pin_code'];
|
||
|
// $response[$i]['patient_cat_id'] = getTableFieldValue('employee_category', 'emp_cat_name', 'emp_cat_id', $row['patient_cat_id'], '');
|
||
|
// $response[$i]['status'] = $row['status'];
|
||
|
// $response[$i]['ohc_type_id'] = $row['ohc_type_id'];
|
||
|
// $response[$i]['email_id'] = $row['email_id'];
|
||
|
// $response[$i]['photo'] = $row['photo'];
|
||
|
// $response[$i]['personal_phone'] = $row['personal_phone'];
|
||
|
// $response[$i]['secondary_contact_no'] = $row['secondary_contact_no'];
|
||
|
// $response[$i]['health_advices'] = getTableFieldValue('health_advice', 'health_advice_name', 'health_advice_id', $row['health_advices'], '');
|
||
|
// $response[$i]['health_risks'] =getTableFieldValue('health_risk', 'health_risk_name', 'health_risk_id', $row['health_risks'], '');
|
||
|
// $response[$i]['relation_type'] = $row['relation_type'];
|
||
|
// $response[$i]['doj'] =date_format( date_create($row['doj']) ,"d-m-Y");
|
||
|
// $response[$i]['primary_phone'] = $row['primary_phone'];
|
||
|
// $i++;
|
||
|
// }
|
||
|
// error_log(print_r($response,true));
|
||
|
// echo json_encode($response, JSON_PRETTY_PRINT);
|
||
|
// }
|
||
|
// }
|
||
|
error_reporting(0);
|
||
|
include "../includes/config/config.php";
|
||
|
include "functions.php";
|
||
|
include 'log_entry.php';
|
||
|
|
||
|
$patientsList_array =array();
|
||
|
$patient_array = array();
|
||
|
$checkup_array = array();
|
||
|
$checkupitem_array = array();
|
||
|
$appintment_array = array();
|
||
|
$sickness_array = array();
|
||
|
$medicine_array = array();
|
||
|
$page = $limit = $search="";
|
||
|
|
||
|
$page = $_REQUEST['_page'];
|
||
|
$limit = $_REQUEST['_limit'];
|
||
|
$search = $_REQUEST['_search'];
|
||
|
|
||
|
$sql_opd = "SELECT * from patient_master where id = '".$_REQUEST['id']."'";
|
||
|
error_log("OPD::" .$sql_opd);
|
||
|
$fetch_patients = mysqli_query($conn, $sql_opd) or die(mysqli_error($conn));
|
||
|
while ($row = mysqli_fetch_assoc($fetch_patients)) {
|
||
|
|
||
|
$dateOfBirth = $row['dob'];
|
||
|
$today = date("Y-m-d");
|
||
|
$diff = date_diff(date_create($dateOfBirth), date_create($today));
|
||
|
if( $row['gender'] == 'M' ) { $gender = 'MALE'; } else if ($row['gender'] == 'F') { $gender = 'FEMALE'; } else { $gender = 'Other'; }
|
||
|
$patient_array['id'] = $row['id'];
|
||
|
$patient_array['age'] = $diff->format('%y');
|
||
|
$patient_array['emp_code'] = $row['emp_code'];
|
||
|
$patient_array['patient_name'] = $row['patient_name'];
|
||
|
$patient_array['father_name'] = $row['father_name'];
|
||
|
$patient_array['dob'] = date_format( date_create($row['dob']) ,"d-m-Y");
|
||
|
$patient_array['gender'] = $gender;
|
||
|
$patient_array['aadhar_no'] = $row['aadhar_no'];
|
||
|
$patient_array['village'] = $row['village'];
|
||
|
$patient_array['post'] = $row['post'];
|
||
|
$patient_array['ps'] = $row['ps'];
|
||
|
$patient_array['tehsil'] = $row['tehsil'];
|
||
|
$patient_array['district'] = $row['district'];
|
||
|
$patient_array['primary_contact_no'] = $row['primary_contact_no'];
|
||
|
$patient_array['state'] = $row['state'];
|
||
|
$patient_array['pin_code'] = $row['pin_code'];
|
||
|
$patient_array['patient_cat_id'] = getTableFieldValue('employee_category', 'emp_cat_name', 'emp_cat_id', $row['patient_cat_id'], '');
|
||
|
$patient_array['status'] = $row['status'];
|
||
|
$patient_array['ohc_type_id'] = $row['ohc_type_id'];
|
||
|
$patient_array['email_id'] = $row['email_id'];
|
||
|
$patient_array['photo'] = $row['photo'];
|
||
|
$patient_array['personal_phone'] = $row['personal_phone'];
|
||
|
$patient_array['secondary_contact_no'] = $row['secondary_contact_no'];
|
||
|
$patient_array['health_advices'] = getTableFieldValue('health_advice', 'health_advice_name', 'health_advice_id', $row['health_advices'], '');
|
||
|
$patient_array['health_risks'] =getTableFieldValue('health_risk', 'health_risk_name', 'health_risk_id', $row['health_risks'], '');
|
||
|
$patient_array['relation_type'] = $row['relation_type'];
|
||
|
$patient_array['doj'] =date_format( date_create($row['doj']) ,"d-m-Y");
|
||
|
$patient_array['primary_phone'] = $row['primary_phone'];
|
||
|
|
||
|
$patient_array['Sickness'] = array();
|
||
|
$fetch_sickness = mysqli_query($conn, "select * from sickness where emp_id='".$row['id']."'"
|
||
|
) or die(mysqli_error($conn));
|
||
|
$d=1;
|
||
|
while ($row_sickness = mysqli_fetch_assoc($fetch_sickness)) {
|
||
|
$sickness_array['srno'] = $d;
|
||
|
$sickness_array['sickness_date'] =date_format(date_create($row_sickness['sickness_date']), "d-M-Y ");
|
||
|
$sickness_array['ailment_name']=getTableFieldValue('ailment', 'ailment_name', 'ailment_id', $row_sickness['ailment_name']);
|
||
|
$sickness_array['doctor_last_attended']=getTableFieldValue('patient_master', 'patient_name', 'id', $row_sickness['doctor_last_attended']);
|
||
|
array_push($patient_array['Sickness'],$sickness_array);
|
||
|
$d++;
|
||
|
|
||
|
}
|
||
|
$patient_array['checkups'] = array();
|
||
|
$fetch_checkup = mysqli_query($conn, "SELECT * from checkup_form where emp_id='".$row['id']."'"
|
||
|
) or die(mysqli_error($conn));
|
||
|
$d=1;
|
||
|
while ($row_checkup = mysqli_fetch_assoc($fetch_checkup)) {
|
||
|
$checkup_array['srno'] = $d;
|
||
|
$checkup_array['checkup_type_id'] = getTableFieldValue('checkup_type', 'checkup_type_name', 'checkup_type_id', $row_checkup['checkup_type_id']);
|
||
|
$checkup_array['checkup_date'] =date_format(date_create($row_checkup['checkup_date']), "d-M-Y ");
|
||
|
$checkup_array['checkup_id'] =$row_checkup['checkup_id'];
|
||
|
$checkup_array['DIVISION'] =getTableFieldValue('bussiness_unit', 'bu_name', 'bu_id', $row_checkup['bu_id'], '');
|
||
|
$checkup_array['designation'] =getFieldFromTable('designation_name', 'designation', 'designation_id', $row_checkup['designation_id']);
|
||
|
$checkup_array['ticket_no'] =$row_checkup['ticket_no'];
|
||
|
$checkup_array['blood_group'] =$row_checkup['blood_group'];
|
||
|
$checkup_array['department'] =getFieldFromTable('dept_name', 'department', 'dept_id', $row_checkup['dept_id']);
|
||
|
$emp_id=getTableFieldValue('tbl_users', 'emp_id', 'user_id', $row_checkup['doctor_last_attended']);
|
||
|
$checkup_array['doctor_last_attended']=getTableFieldValue('patient_master', 'patient_name', 'id', $emp_id);
|
||
|
array_push($patient_array['checkups'],$checkup_array);
|
||
|
$d++;
|
||
|
}
|
||
|
|
||
|
$patient_array['appointment'] = array();
|
||
|
$fetch_appintment = mysqli_query($conn, "select * from employee_appointment where emp_id= '". $row['id'] ."'"
|
||
|
) or die(mysqli_error($conn));
|
||
|
$d=1;
|
||
|
while ($row_appintment = mysqli_fetch_assoc($fetch_appintment)) {
|
||
|
$appintment_array['srno'] = $d;
|
||
|
|
||
|
$appintment_array['appointment_id'] = (int)$row_appintment['appointment_id']??'';
|
||
|
if ($row_appintment['appointment_type'] == 'O'){
|
||
|
$type = "OPD";
|
||
|
}else{
|
||
|
$type = "INJURY";
|
||
|
}
|
||
|
$appintment_array['type'] = $type;
|
||
|
$appintment_array['appointment_date'] =date_format(date_create($row_appintment['appointment_date']??''), "d-M-Y ");
|
||
|
$emp_id=getTableFieldValue('tbl_users', 'emp_id', 'user_id', $row_appintment['doctor_last_attended']??'');
|
||
|
$appintment_array['doctor_last_attended'] =getTableFieldValue('patient_master', 'patient_name', 'id', $emp_id)??'';
|
||
|
$appintment_array['employer_contractor'] = getTableFieldValue('employer_contractor', 'employer_contractor_name', 'id', $row_appintment['employer_contractor_id'])??'';
|
||
|
$appintment_array['designation'] = getTableFieldValue('designation', 'designation_name', 'designation_id', $row_appintment['designation_id'])??'';
|
||
|
$appintment_array['ticket_no'] = $row_appintment['ticket_no']??'';
|
||
|
$appintment_array['DIVISION'] =getTableFieldValue('bussiness_unit', 'bu_name', 'bu_id', $row_appintment['bu_id'], '');
|
||
|
$appintment_array['dept'] = getTableFieldValue('department', 'dept_name', 'dept_id', $row_appintment['dept_id'], '');
|
||
|
$appintment_array['IN_TIME'] = date_format(date_create($appintment_array['appointment_date']), "d-M-Y h:i:sa ");
|
||
|
$appintment_array['clearance_time'] = date_format(date_create($appintment_array['clearance_time']), "d-M-Y h:i:sa ") ??'';
|
||
|
$appintment_array['bp_sbp'] = $row_appintment['bp_sbp']??'';
|
||
|
$appintment_array['bp_dbp'] = $row_appintment['bp_dbp']??'';
|
||
|
$appintment_array['pulse'] = $row_appintment['pulse']??'';
|
||
|
$appintment_array['temperature'] = $row_appintment['temperature']??'';
|
||
|
$appintment_array['weight'] = $row_appintment['weight']??'';
|
||
|
$appintment_array['height'] = $row_appintment['height']??'';
|
||
|
$appintment_array['bmi'] = $row_appintment['bmi']??'';
|
||
|
$appintment_array['health_advices'] =$row_appintment['health_advices_new']??'';
|
||
|
$appintment_array['heart_rate'] = $row_appintment['heart_rate']??'';
|
||
|
$appintment_array['oxygen_supply'] = $row_appintment['oxygen_supply']??'';
|
||
|
$appintment_array['total_cholesterol'] = $row_appintment['total_cholesterol']??'';
|
||
|
$appintment_array['urine'] = $row_appintment['urine_ouput']??'';
|
||
|
$appintment_array['bp'] = $row_appintment['bp']??'';
|
||
|
$appintment_array['case_type'] = $row_appintment['case_type']??'';
|
||
|
$appintment_array['referred_to'] = $row_appintment['referred_to']??'';
|
||
|
$appintment_array['mobility'] = $row_appintment['mobility']??'';
|
||
|
$appintment_array['parts'] = getTableFieldValue('injury_part', 'inj_name', 'inj_id', $row_appintment['injury_parts_new'])??'';
|
||
|
$appintment_array['classification'] =getTableFieldValue('injury_class', 'inj_class_name', 'inj_class_id', $row_appintment['injury_classes_new'])??'';
|
||
|
$appintment_array['trama'] = $row_appintment['trama']??'';
|
||
|
$appintment_array['Follow_up_date'] = date_format(date_create($row_appintment['followup']),"d-M-Y");
|
||
|
$appintment_array['spo2_percent'] = $row_appintment['spo2_percent']??'';
|
||
|
$appintment_array['incident_location'] = $row_appintment['incident_location']??'';
|
||
|
$appintment_array['spo2_percent'] = $row_appintment['spo2_percent']??'';
|
||
|
$appintment_array['blood_sugar_rbs'] = $row_appintment['blood_sugar_rbs']??'';
|
||
|
$appintment_array['blood_sugar_fbs'] = $row_appintment['blood_sugar_fbs']??'';
|
||
|
$appintment_array['blood_sugar_ppbs'] = $row_appintment['blood_sugar_ppbs']??'';
|
||
|
$appintment_array['remarks_rece'] = $row_appintment['remarks_rece'];
|
||
|
$appintment_array['referred_by'] =getFieldFromTable('referred_by', 'referred_by_master', 'id', $row_appintment['referred_by'])??'';
|
||
|
$appintment_array['Precautions'] = $row_appintment['remarks']??'';
|
||
|
$appintment_array['followup_to_opd'] = $row_appintment['followup_to_opd']??'';
|
||
|
$appintment_array['injury_remarks'] = $row_appintment['injury_remarks']??'';
|
||
|
$appintment_array['Leave_Remarks'] = $row_appintment['injury_remarks']??'';
|
||
|
$appintment_array['doc_comment'] = $row_appintment['doc_comment'];
|
||
|
$appintment_array['Investigation_Details'] =nl2br($row_appintment['remarks_rece']);
|
||
|
$appintment_array['injury_procedure'] =nl2br($row_appintment['injury_procedure']??'');
|
||
|
$appintment_array['external_treatments'] = nl2br($row_appintment['external_treatments']??'');
|
||
|
$appintment_array['recommended_tests_new'] = $row_appintment['recommended_tests_new']??'';
|
||
|
$appintment_array['Ecg_Finding'] = nl2br($row_appintment['ecg_findings'])??'';
|
||
|
$appintment_array['Chronic']=getCommaSeperatedValuesForInClause("select abnormality_name from abnormality", "abnormality_id", $row_appintment['abnormalitys']??'');
|
||
|
|
||
|
$ailment_names_ids = $row_appintment['Body_System'];
|
||
|
$ailment_names_ids_array = array();
|
||
|
$ailment_names_ids_array = explode(",", $ailment_names_ids);
|
||
|
$appintment_array['Body_System'] = "";
|
||
|
for ($i = 0; $i < count($ailment_names_ids_array); $i++) {
|
||
|
if ($i == 0) {
|
||
|
$appintment_array['Body_System'] = getTableFieldValue('ailment', 'ailment_name', 'ailment_id', $ailment_names_ids_array[$i]);
|
||
|
} else {
|
||
|
$appintment_array['Body_System'] = $appintment_array['Body_System'] . "," . getTableFieldValue('ailment', 'ailment_name', 'ailment_id', $ailment_names_ids_array[$i]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$referral_ids = $row_appintment['referral'];
|
||
|
$referral_ids_array = array();
|
||
|
$referral_ids_array = explode(",", $referral_ids);
|
||
|
$appintment_array['referral'] = "";
|
||
|
for ($i = 0; $i < count($referral_ids_array); $i++) {
|
||
|
if ($i == 0) {
|
||
|
$appintment_array['referral']= getTableFieldValue('referral_point', 'referral_point_name', 'referral_point_id', $referral_ids_array[$i]);
|
||
|
} else {
|
||
|
$appintment_array['referral']= $appintment_array['referral']. "," . getTableFieldValue('referral_point', 'referral_point_name', 'referral_point_id', $referral_ids_array[$i]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$injury_type_ids = $row_appintment['injury_types_new']??'';
|
||
|
$injury_type_ids_array = array();
|
||
|
$injury_type_ids_array = explode(",", $injury_type_ids);
|
||
|
$appintment_array['typeinjury']= "";
|
||
|
for ($i = 0; $i < count($injury_type_ids_array); $i++) {
|
||
|
if ($i == 0) {
|
||
|
$appintment_array['typeinjury'] = getTableFieldValue('injury_type', 'injury_type_name', 'injury_type_id', $injury_type_ids_array[$i]);
|
||
|
} else {
|
||
|
$appintment_array['typeinjury'] = $appintment_array['typeinjury'] . "," . getTableFieldValue('injury_type', 'injury_type_name', 'injury_type_id', $injury_type_ids_array[$i]);
|
||
|
}
|
||
|
}
|
||
|
$complaints_ids = $row_appintment['complaints']??'';
|
||
|
$complaints_ids_array = array();
|
||
|
$complaints_ids_array = explode(",", $complaints_ids);
|
||
|
$appintment_array['complaints'] = "";
|
||
|
for ($i = 0; $i < count($complaints_ids_array); $i++) {
|
||
|
if ($i == 0) {
|
||
|
$appintment_array['complaints'] = getTableFieldValue('complaints', 'complaint', 'complaint_id', $complaints_ids_array[$i]??'');
|
||
|
} else {
|
||
|
$appintment_array['complaints'] = $appintment_array['complaints'] . "," . getTableFieldValue('complaints', 'complaint', 'complaint_id', $complaints_ids_array[$i]??'');
|
||
|
}
|
||
|
}
|
||
|
$findings_ids = $row_appintment['examination_remarks']??'';
|
||
|
$findings_ids_array = array();
|
||
|
$findings_ids_array = explode(",", $findings_ids);
|
||
|
$appintment_array['examination_remarks'] = "";
|
||
|
for ($i = 0; $i < count($findings_ids_array); $i++) {
|
||
|
if ($i == 0) {
|
||
|
$appintment_array['examination_remarks'] = getTableFieldValue('examination_findings', 'examination_finding', 'id', $findings_ids_array[$i]??'');
|
||
|
} else {
|
||
|
$appintment_array['examination_remarks'] = $appintment_array['examination_remarks'] . "," . getTableFieldValue('examination_findings', 'examination_finding', 'id', $findings_ids_array[$i]??'');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$ailment_names_ids = $row_appintment['Diagnosis']??'';
|
||
|
$ailment_names_ids_array = array();
|
||
|
$ailment_names_ids_array = explode(",", $ailment_names_ids);
|
||
|
$appintment_array['Diagnosis'] = "";
|
||
|
for ($i = 0; $i < count($ailment_names_ids_array); $i++) {
|
||
|
if ($i == 0) {
|
||
|
$appintment_array['Diagnosis'] = getTableFieldValue('ailment', 'ailment_name', 'ailment_id', $ailment_names_ids_array[$i]);
|
||
|
} else {
|
||
|
$appintment_array['Diagnosis'] = $appintment_array['diagnosis'] . "," . getTableFieldValue('ailment', 'ailment_name', 'ailment_id', $ailment_names_ids_array[$i]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$appintment_array['medicines'] = array();
|
||
|
$fetch_appintment1 = mysqli_query($conn, "SELECT
|
||
|
item_id,
|
||
|
frequency_id,
|
||
|
for_days,item_qty,issued_qty,dosage,dosage_category_id,timing_id
|
||
|
FROM treatment
|
||
|
WHERE appointment_id = ".$row_appintment['appointment_id'].""
|
||
|
) or die(mysqli_error($conn));
|
||
|
$d=1;
|
||
|
while ($row_appintment1 = mysqli_fetch_assoc($fetch_appintment1)) {
|
||
|
$medicine_array['srno'] = $d;
|
||
|
$medicine_array['item_id']=(int)$row_appintment1['item_id'];
|
||
|
$medicine_array['item_name']=getItemWithFormName($row_appintment1['item_id']);
|
||
|
$medicine_array['frequency_id']=getTableFieldValue('medicine_frequency', 'frequency_description', 'frequency_id', $row_appintment1['frequency_id'], '');
|
||
|
$medicine_array['for_days']=$row_appintment1['for_days'];
|
||
|
$medicine_array['item_qty']=$row_appintment1['item_qty'];
|
||
|
$medicine_array['issued_qty']=$row_appintment1['issued_qty'];
|
||
|
$medicine_array['dosage']=$row_appintment1['dosage'];
|
||
|
$medicine_array['dosage_category_id']=getTableFieldValue('dosage_category','dosage_category','dosage_category_id',$row_appintment1['dosage_category_id']);
|
||
|
$medicine_array['timing_id']=getTableFieldValue('medicine_timings', 'timing_description', 'timing_id', $row_appintment1['timing_id']);
|
||
|
array_push($appintment_array['medicines'],$medicine_array);
|
||
|
$d++;
|
||
|
}
|
||
|
array_push($patient_array['appointment'],$appintment_array);
|
||
|
$d++;
|
||
|
|
||
|
}
|
||
|
array_push($patientsList_array,$patient_array);
|
||
|
}
|
||
|
$jsonData = json_encode($patientsList_array, JSON_PRETTY_PRINT);
|
||
|
|
||
|
|
||
|
echo $jsonData;
|
||
|
|
||
|
?>
|