ESH/save_medical_examination.php
2024-10-23 18:28:06 +05:30

1150 lines
45 KiB
PHP

<?php
include('includes/config/config.php');
include('includes/functions.php');
include('log_entry.php');
error_log("Start Printing Request Attributes");
foreach ($_REQUEST as $key => $value) {
error_log($key . " : " . $value . "<br />\r\n");
}
error_log("End Printing Request Attributes");
// error_reporting(E_ERROR | E_PARSE);
error_reporting(E_ERROR | E_PARSE);
$data = array();
$medical_exam_id = $_POST['medical_exam_id'];
error_log("MEDICAL EXAM ID:::" . $medical_exam_id);
$patient_id = $_POST['patient_id'];
error_log($patient_id);
$forward_status = $_POST['forward_status'];
//if forward status is not set then for Doctore default should be D and for medical Default should be M
//so that they can edit
if (!empty($medical_exam_id) && $forward_status == null || $forward_status == '') {
if ($_SESSION['RoleCode'] == 'DOC') {
$forward_status = 'D';
} else {
$forward_status = 'M';
}
}
$ohc_type = $_SESSION['current_ohcttype'];
$data['medical_exam_id'] = $medical_exam_id;
$peme_no = $_POST['peme_no'];
$pohc_no = $_POST['pohc_no'];
$air_audio_remarks = $_POST['air_audio_remarks'];
$bone_audio_remarks = $_POST['bone_audio_remarks'];
$health_risks = strtoupper($_POST['health_risks']);
$health_advices = strtoupper($_POST['health_advices']);
$health_advices = handleDynamicMasterInsert("health_advice", "health_advice_name", "health_advice_id", $health_advices, true);
// error_log("health_advices:" . implode(',', $health_advices));
$health_advices = getMultiValuedSelectData($health_advices);
// error_log("health_advices:" . $health_advices);
$health_risks = handleDynamicMasterInsert("health_risk", "health_risk_name", "health_risk_id", $health_risks, true);
// error_log("health_risks:" . implode(',', $health_risks));
$health_risks = getMultiValuedSelectData($health_risks);
// error_log("health_risks:" . $health_risks);
if ($_POST['conduction_type'] == 'AIR CONDUCTION') {
$bone_cond_left = NULL;
$bone_cond_right = NULL;
$air_cond_left = $_POST['air_cond_left'];
$air_cond_right = $_POST['air_cond_right'];
}
if ($_POST['conduction_type'] == 'BONE CONDUCTION') {
$air_cond_left = NULL;
$air_cond_right = NULL;
$bone_cond_left = $_POST['bone_cond_left'];
$bone_cond_right = $_POST['bone_cond_right'];
}
$approval_date_str = $_POST['approval_date'];
if (!isset($_POST['approval_date'])) {
$approval_date_str = " CURDATE() ";
} else {
$approval_date_str = " STR_TO_DATE('" . $_POST['approval_date'] . "','%d/%m/%Y') ";
}
begin();
if ($forward_status != 'A') {
error_log("forward_status supposed to be not for approval:" . $forward_status);
// check duplicate entry for the same date..
if (empty($medical_exam_id)) {
$row_existing = runSqlGenericSingleRow("select medical_exam_id from medical_examination where patient_id='" . $_POST['patient_id'] . "' and task='" . $_POST['task'] . "' and date(medical_entry_date)=CURRENT_DATE() ");
if ($row_existing != null) {
// existing found.. we will instead update the existing
error_log("existing entry found: " . $row_existing['medical_exam_id']);
$medical_exam_id = $row_existing['medical_exam_id'];
}
}
// $row_existing_status = runSqlGenericSingleRow ( "select forward_status from medical_examination where patient_id='" . $_POST ['patient_id'] . "' and task='" . $_POST ['task'] . "' and date(medical_entry_date)=CURRENT_DATE() " );
// error_log("STATUS".$row_existing_status);
// if($row_existing_status != null){
// $forward_status = $row_existing_status;
// }
if (!empty($medical_exam_id)) {
error_log("update case");
$initquery = " update medical_examination ";
$endquery = " where medical_exam_id = '" . $medical_exam_id . "' ";
$data['medical_exam_id'] = $medical_exam_id;
} else {
error_log("Insert case");
$initquery = " insert into medical_examination ";
$medical_entry_date = date('Y/m/d H:i:s', time());
$endquery = ", medical_entry_date='$medical_entry_date' ";
}
$optional_params = "";
if (isset($_POST['hip'])) {
$optional_params .= ", hip='" . addslashes($_POST['hip']) . "'";
}
if (isset($_POST['weight'])) {
$optional_params .= ", weight='" . addslashes($_POST['weight']) . "'";
}
if (isset($_POST['height'])) {
$optional_params .= ", height='" . addslashes($_POST['height']) . "'";
}
if (isset($_POST['waist'])) {
$optional_params .= ", waist='" . addslashes($_POST['waist']) . "'";
}
if (isset($_POST['peme_no'])) {
$optional_params .= ", peme_no='" . addslashes($_POST['peme_no']) . "'";
}
if (isset($pohc_no)) {
$optional_params .= ", pohc_no='" . addslashes($pohc_no) . "'";
}
if (isset($_POST['medical_entry_date'])) {
$optional_params .= ", medical_entry_date=STR_TO_DATE('" . $_POST['medical_entry_date'] . "','%d/%m/%Y') ";
}
if (isset($_POST['patient_id'])) {
$optional_params .= ", patient_id='" . ($_POST['patient_id']) . "' ";
}
if (isset($_POST['medical_examination_status'])) {
$optional_params .= ", medical_examination_status='" . addslashes($_POST['medical_examination_status']) . "'";
}
if (isset($_POST['regular_medication'])) {
$optional_params .= ", regular_medication='" . addslashes($_POST['regular_medication']) . "'";
}
if (isset($_POST['task'])) {
$optional_params .= ", task='" . addslashes($_POST['task']) . "'";
}
if (isset($_POST['present_complaint'])) {
$optional_params .= ", present_complaint='" . addslashes($_POST['present_complaint']) . "'";
}
if ($_SESSION['RoleCode'] == 'DOC' && isset($_POST['opinion_mo'])) {
$optional_params .= ", opinion_mo='" . addslashes($_POST['opinion_mo']) . "'";
}
if (isset($_POST['hbsag'])) {
$optional_params .= ", hbsag='" . addslashes($_POST['hbsag']) . "'";
}
if (isset($_POST['hiv'])) {
$optional_params .= ", hiv='" . addslashes($_POST['hiv']) . "'";
}
if (isset($_POST['hcv'])) {
$optional_params .= ", hcv='" . addslashes($_POST['hcv']) . "'";
}
if (isset($_POST['ldl'])) {
$optional_params .= ", ldl='" . addslashes($_POST['ldl']) . "'";
}
if (isset($_POST['vldl'])) {
$optional_params .= ", vldl='" . addslashes($_POST['vldl']) . "'";
}
if (isset($_POST['hdl'])) {
$optional_params .= ", hdl='" . addslashes($_POST['hdl']) . "'";
}
if (isset($_POST['triglycerides'])) {
$optional_params .= ", triglycerides='" . addslashes($_POST['triglycerides']) . "'";
}
if (isset($_POST['total_cholestrol'])) {
$optional_params .= ", total_cholestrol='" . addslashes($_POST['total_cholestrol']) . "'";
}
if (isset($_POST['near_with_right_eye'])) {
$optional_params .= ", near_with_right_eye='" . addslashes($_POST['near_with_right_eye']) . "'";
}
if (isset($_POST['eye_remarks'])) {
$optional_params .= ", eye_remarks='" . addslashes($_POST['eye_remarks']) . "'";
}
if (isset($_POST['bp'])) {
$optional_params .= ", bp='" . addslashes($_POST['bp']) . "'";
}
if (isset($_POST['pulse'])) {
$optional_params .= ", pulse='" . addslashes($_POST['pulse']) . "'";
}
if (isset($_POST['bmi'])) {
$optional_params .= ", bmi='" . addslashes($_POST['bmi']) . "'";
}
if (isset($_POST['any_other_eye_disease'])) {
$optional_params .= ", any_other_eye_disease='" . addslashes($_POST['any_other_eye_disease']) . "'";
}
if (isset($_POST['nails'])) {
$optional_params .= ", nails='" . addslashes($_POST['nails']) . "'";
}
if (isset($_POST['dlc_l'])) {
$optional_params .= ", dlc_l='" . addslashes($_POST['dlc_l']) . "'";
}
if (isset($_POST['dis_without_left_eye'])) {
$optional_params .= ", dis_without_left_eye='" . addslashes($_POST['dis_without_left_eye']) . "'";
}
if (isset($_POST['dis_without_right_eye'])) {
$optional_params .= ", dis_without_right_eye='" . addslashes($_POST['dis_without_right_eye']) . "'";
}
if (isset($_POST['fev1'])) {
$optional_params .= ", fev1='" . addslashes($_POST['fev1']) . "'";
}
if (isset($_POST['fev1_fvc'])) {
$optional_params .= ", fev1_fvc='" . addslashes($_POST['fev1_fvc']) . "'";
}
if (isset($_POST['peak_expiratory_flow'])) {
$optional_params .= ", peak_expiratory_flow='" . addslashes($_POST['peak_expiratory_flow']) . "'";
}
if (isset($_POST['fvc'])) {
$optional_params .= ", fvc='" . addslashes($_POST['fvc']) . "'";
}
if (isset($_POST['spiro_remarks'])) {
$optional_params .= ", spirometry_remarks='" . addslashes($_POST['spiro_remarks']) . "'";
}
if (isset($_POST['abdomen'])) {
$optional_params .= ", abdomen='" . addslashes($_POST['abdomen']) . "'";
}
if (isset($_POST['dis_with_right_eye'])) {
$optional_params .= ", dis_with_right_eye='" . addslashes($_POST['dis_with_right_eye']) . "'";
}
if (isset($_POST['near_without_right_eye'])) {
$optional_params .= ", near_without_right_eye='" . addslashes($_POST['near_without_right_eye']) . "'";
}
if (isset($_POST['dlc_e'])) {
$optional_params .= ", dlc_e='" . addslashes($_POST['dlc_e']) . "'";
}
if (isset($_POST['dlc_b'])) {
$optional_params .= ", dlc_b='" . addslashes($_POST['dlc_b']) . "'";
}
if (isset($_POST['dlc_m'])) {
$optional_params .= ", dlc_m='" . addslashes($_POST['dlc_m']) . "'";
}
if (isset($_POST['dis_with_left_eye'])) {
$optional_params .= ", dis_with_left_eye='" . addslashes($_POST['dis_with_left_eye']) . "'";
}
if (isset($_POST['rs'])) {
$optional_params .= ", rs='" . addslashes($_POST['rs']) . "'";
}
if (isset($_POST['color_vision'])) {
$optional_params .= ", color_vision='" . addslashes($_POST['color_vision']) . "'";
}
if (isset($_POST['skin'])) {
$optional_params .= ", skin='" . addslashes($_POST['skin']) . "'";
}
if (isset($_POST['near_with_left_eye'])) {
$optional_params .= ", near_with_left_eye='" . addslashes($_POST['near_with_left_eye']) . "'";
}
if (isset($_POST['near_without_left_eye'])) {
$optional_params .= ", near_without_left_eye='" . addslashes($_POST['near_without_left_eye']) . "'";
}
if (isset($_POST['bone_cond_left'])) {
$optional_params .= ", bone_cond_left='" . addslashes($_POST['bone_cond_left']) . "'";
}
if (isset($_POST['bone_cond_right'])) {
$optional_params .= ", bone_cond_right='" . addslashes($_POST['bone_cond_right']) . "'";
}
if (isset($_POST['air_cond_right'])) {
$optional_params .= ", air_cond_right='" . addslashes($_POST['air_cond_right']) . "'";
}
if (isset($_POST['air_cond_left'])) {
$optional_params .= ", air_cond_left='" . addslashes($_POST['air_cond_left']) . "'";
}
if (isset($_POST['conduction_type'])) {
$optional_params .= ", conduction_type='" . addslashes($_POST['conduction_type']) . "'";
}
if (isset($air_audio_remarks)) {
$optional_params .= ", air_audio_remarks='" . addslashes($air_audio_remarks) . "'";
}
if (isset($bone_audio_remarks)) {
$optional_params .= ", bone_audio_remarks='" . addslashes($bone_audio_remarks) . "'";
}
if (isset($_POST['stool_re_me'])) {
$optional_params .= ", stool_re_me='" . addslashes($_POST['stool_re_me']) . "'";
}
if (isset($_POST['urine_re_me'])) {
$optional_params .= ", urine_re_me='" . addslashes($_POST['urine_re_me']) . "'";
}
if (isset($_POST['urine_re_me_comments'])) {
$optional_params .= ", urine_re_me_comments='" . addslashes($_POST['urine_re_me_comments']) . "'";
}
if (isset($_POST['chest_radiograph'])) {
$optional_params .= ", chest_radiograph='" . addslashes($_POST['chest_radiograph']) . "'";
}
if (isset($_POST['ent'])) {
$optional_params .= ", ent='" . addslashes($_POST['ent']) . "'";
}
if (isset($_POST['cns'])) {
$optional_params .= ", cns='" . addslashes($_POST['cns']) . "'";
}
if (isset($_POST['cns_comments'])) {
$optional_params .= ", cns_comments='" . addslashes($_POST['cns_comments']) . "'";
}
if (isset($_POST['musculo_skeletal'])) {
$optional_params .= ", musculo_skeletal='" . addslashes($_POST['musculo_skeletal']) . "'";
}
if (isset($_POST['peak_expiratory_flow_pre'])) {
$optional_params .= ", peak_expiratory_flow_pre='" . addslashes($_POST['peak_expiratory_flow_pre']) . "'";
}
if (isset($_POST['blood_group'])) {
$optional_params .= ", blood_group='" . addslashes($_POST['blood_group']) . "'";
}
if (isset($_POST['fev1_fvc_post'])) {
$optional_params .= ", fev1_fvc_post='" . addslashes($_POST['fev1_fvc_post']) . "'";
}
if (isset($_POST['fev1_post'])) {
$optional_params .= ", fev1_post='" . addslashes($_POST['fev1_post']) . "'";
}
if (isset($_POST['fev1_pre'])) {
$optional_params .= ", fev1_pre='" . addslashes($_POST['fev1_pre']) . "'";
}
if (isset($_POST['fvc_post'])) {
$optional_params .= ", fvc_post='" . addslashes($_POST['fvc_post']) . "'";
}
if (isset($_POST['fvc_pre'])) {
$optional_params .= ", fvc_pre='" . addslashes($_POST['fvc_pre']) . "'";
}
if (isset($_POST['profusion_opacities'])) {
$optional_params .= ", profusion_opacities='" . addslashes($_POST['profusion_opacities']) . "'";
}
if (isset($_POST['fev1_fvc_pre'])) {
$optional_params .= ", fev1_fvc_pre='" . addslashes($_POST['fev1_fvc_pre']) . "'";
}
if (isset($_POST['tmt_findings'])) {
$optional_params .= ", tmt_findings='" . addslashes($_POST['tmt_findings']) . "'";
}
if (isset($_POST['ecg_findings'])) {
$optional_params .= ", ecg_findings='" . addslashes($_POST['ecg_findings']) . "'";
}
if (isset($_POST['any_other_sound'])) {
$optional_params .= ", any_other_sound='" . addslashes($_POST['any_other_sound']) . "'";
}
if (isset($_POST['s2'])) {
$optional_params .= ", s2='" . addslashes($_POST['s2']) . "'";
}
if (isset($_POST['s1'])) {
$optional_params .= ", s1='" . addslashes($_POST['s1']) . "'";
}
if (isset($_POST['hb'])) {
$optional_params .= ", hb='" . addslashes($_POST['hb']) . "'";
}
if (isset($_POST['opinion_remarks_medical_assistant'])) {
$optional_params .= ", opinion_remarks_medical_assistant='" . addslashes($_POST['opinion_remarks_medical_assistant']) . "'";
}
if (isset($_POST['physical_status'])) {
$optional_params .= ", physical_status='" . addslashes($_POST['physical_status']) . "'";
}
if (isset($_POST['ident_of_individual_colors'])) {
$optional_params .= ", ident_of_individual_colors='" . addslashes($_POST['ident_of_individual_colors']) . "'";
}
if (isset($_POST['cvs'])) {
$optional_params .= ", cvs='" . addslashes($_POST['cvs']) . "'";
}
if (isset($_POST['pallor'])) {
$optional_params .= ", pallor='" . addslashes($_POST['pallor']) . "'";
}
if (isset($_POST['peak_expiratory_flow_post'])) {
$optional_params .= ", peak_expiratory_flow_post='" . addslashes($_POST['peak_expiratory_flow_post']) . "'";
}
if (isset($_POST['peak_expiratory_flow_pre'])) {
$optional_params .= ", peak_expiratory_flow_pre='" . addslashes($_POST['peak_expiratory_flow_pre']) . "'";
}
if (isset($_POST['psa'])) {
$optional_params .= ", psa='" . addslashes($_POST['psa']) . "'";
}
if (isset($_POST['lipid_profile'])) {
$optional_params .= ", lipid_profile='" . addslashes($_POST['lipid_profile']) . "'";
}
if (isset($_POST['vdrl'])) {
$optional_params .= ", vdrl='" . addslashes($_POST['vdrl']) . "'";
}
if (isset($_POST['tlc'])) {
$optional_params .= ", tlc='" . addslashes($_POST['tlc']) . "'";
}
if (isset($_POST['dlc_n'])) {
$optional_params .= ", dlc_n='" . addslashes($_POST['dlc_n']) . "'";
}
if (isset($_POST['platelets'])) {
$optional_params .= ", platelets='" . addslashes($_POST['platelets']) . "'";
}
if (isset($_POST['s_urea'])) {
$optional_params .= ", s_urea='" . addslashes($_POST['s_urea']) . "'";
}
if (isset($_POST['s_creatinine'])) {
$optional_params .= ", s_creatinine='" . addslashes($_POST['s_creatinine']) . "'";
}
if (isset($_POST['blood_sugar_fbs'])) {
$optional_params .= ", blood_sugar_fbs='" . addslashes($_POST['blood_sugar_fbs']) . "'";
}
if (isset($_POST['blood_sugar_ppbs'])) {
$optional_params .= ", blood_sugar_ppbs='" . addslashes($_POST['blood_sugar_ppbs']) . "'";
}
if (isset($_POST['blood_sugar_rbs'])) {
$optional_params .= ", blood_sugar_rbs='" . addslashes($_POST['blood_sugar_rbs']) . "'";
}
if (isset($_POST['blood_sugar_hb1ac'])) {
$optional_params .= ", blood_sugar_hb1ac='" . addslashes($_POST['blood_sugar_hb1ac']) . "'";
}
if ($_SESSION['RoleCode'] != 'DOC') {
$optional_params .= ", medical_attend='" . addslashes($_SESSION['user_id']) . "'";
}
if (isset($_POST['conversational_hearing'])) {
$optional_params .= ", conversational_hearing='" . addslashes($_POST['conversational_hearing']) . "'";
}
if (isset($_POST['auroscopy'])) {
$optional_params .= ", auroscopy='" . addslashes($_POST['auroscopy']) . "'";
}
if (isset($_POST['eac'])) {
$optional_params .= ", eac='" . addslashes($_POST['eac']) . "'";
}
if (isset($_POST['nose'])) {
$optional_params .= ", nose='" . addslashes($_POST['nose']) . "'";
}
if (isset($_POST['throat'])) {
$optional_params .= ", throat='" . addslashes($_POST['throat']) . "'";
}
if (isset($_POST['opinion_remarks'])) {
$optional_params .= ", opinion_remarks='" . addslashes($_POST['opinion_remarks']) . "'";
}
if (isset($_POST['any_other'])) {
$optional_params .= ", any_other='" . addslashes($_POST['any_other']) . "'";
}
if (isset($_POST['pap_smear'])) {
$optional_params .= ", pap_smear='" . addslashes($_POST['pap_smear']) . "'";
}
if (isset($_POST['mammography'])) {
$optional_params .= ", mammography='" . addslashes($_POST['mammography']) . "'";
}
if (isset($_POST['dental_exam_report'])) {
$optional_params .= ", dental_exam_report='" . addslashes($_POST['dental_exam_report']) . "'";
}
if (isset($_POST['thyroid_profile'])) {
$optional_params .= ", thyroid_profile='" . addslashes($_POST['thyroid_profile']) . "'";
}
if (isset($_POST['live_function_test'])) {
$optional_params .= ", live_function_test='" . addslashes($_POST['live_function_test']) . "'";
}
if (isset($_POST['type'])) {
$optional_params .= ", type='" . addslashes($_POST['type']) . "'";
}
if (isset($_POST['grade'])) {
$optional_params .= ", grade='" . addslashes($_POST['grade']) . "'";
}
if (isset($_POST['fistula'])) {
$optional_params .= ", fistula='" . addslashes($_POST['fistula']) . "'";
}
if (isset($_POST['piles_details'])) {
$optional_params .= ", piles_details='" . addslashes($_POST['piles_details']) . "'";
}
if (isset($_POST['phimosis'])) {
$optional_params .= ", phimosis='" . addslashes($_POST['phimosis']) . "'";
}
if (isset($_POST['hydrocele'])) {
$optional_params .= ", hydrocele='" . addslashes($_POST['hydrocele']) . "'";
}
if (isset($_POST['hernia_details'])) {
$optional_params .= ", hernia_details='" . addslashes($_POST['hernia_details']) . "'";
}
if (isset($_POST['vibration_syndrome'])) {
$optional_params .= ", vibration_syndrome='" . addslashes($_POST['vibration_syndrome']) . "'";
}
if (isset($_POST['reflexes'])) {
$optional_params .= ", reflexes='" . addslashes($_POST['reflexes']) . "'";
}
if (isset($_POST['vertigo'])) {
$optional_params .= ", vertigo='" . addslashes($_POST['vertigo']) . "'";
}
if (isset($_POST['motor_function'])) {
$optional_params .= ", motor_function='" . addslashes($_POST['motor_function']) . "'";
}
if (isset($_POST['higher_function'])) {
$optional_params .= ", higher_function='" . addslashes($_POST['higher_function']) . "'";
}
if (isset($_POST['speech'])) {
$optional_params .= ", speech='" . addslashes($_POST['speech']) . "'";
}
if (isset($_POST['esr'])) {
$optional_params .= ", esr='" . addslashes($_POST['esr']) . "'";
}
if (isset($_POST['bun'])) {
$optional_params .= ", bun='" . addslashes($_POST['bun']) . "'";
}
if (isset($_POST['uric_acid'])) {
$optional_params .= ", uric_acid='" . addslashes($_POST['uric_acid']) . "'";
}
if (isset($_POST['acid_phosphatase'])) {
$optional_params .= ", acid_phosphatase='" . addslashes($_POST['acid_phosphatase']) . "'";
}
if (isset($_POST['appearance'])) {
$optional_params .= ", appearance='" . addslashes($_POST['appearance']) . "'";
}
if (isset($_POST['any_other_abnormality'])) {
$optional_params .= ", any_other_abnormality='" . addslashes($_POST['any_other_abnormality']) . "'";
}
if (isset($_POST['tenderness'])) {
$optional_params .= ", tenderness='" . addslashes($_POST['tenderness']) . "'";
}
if (isset($_POST['speen'])) {
$optional_params .= ", speen='" . addslashes($_POST['speen']) . "'";
}
if (isset($_POST['liver'])) {
$optional_params .= ", liver='" . addslashes($_POST['liver']) . "'";
}
if (isset($_POST['history_parameter'])) {
$optional_params .= ", past_present_illness='" . addslashes($_POST['history_parameter']) . "'";
}
if ($_SESSION['RoleCode'] == 'DOC' && isset($_POST['sign_medical_officer'])) {
$optional_params .= ", sign_medical_officer='" . addslashes($_POST['sign_medical_officer']) . "'";
}
if ($_SESSION['RoleCode'] != 'DOC' && isset($_POST['signature_medical_assistant'])) {
$optional_params .= ", sign_medical_ass='" . addslashes($_POST['signature_medical_assistant']) . "'";
}
if (isset($_POST['sugar'])) {
$optional_params .= ", sugar='" . addslashes($_POST['sugar']) . "'";
}
if (isset($_POST['other_relevant_findings'])) {
$optional_params .= ", other_relevant_findings='" . addslashes($_POST['other_relevant_findings']) . "'";
}
if (isset($_POST['epithelial_cells'])) {
$optional_params .= ", epithelial_cells='" . addslashes($_POST['epithelial_cells']) . "'";
}
if (isset($_POST['rbcs'])) {
$optional_params .= ", rbcs='" . addslashes($_POST['rbcs']) . "'";
}
if (isset($_POST['pus_cells'])) {
$optional_params .= ", pus_cells='" . addslashes($_POST['pus_cells']) . "'";
}
if ($_SESSION['RoleCode'] == 'DOC' && isset($_POST['approval_date'])) {
$optional_params .= ", approval_date=STR_TO_DATE('" . $_POST['approval_date'] . "','%d/%m/%Y') ";
}
if (isset($_POST['due_date'])) {
$optional_params .= ", next_due_date=STR_TO_DATE('" . $_POST['due_date'] . "','%d/%m/%Y')";
}
if (isset($_POST['sugar'])) {
$optional_params .= ", sugar='" . addslashes($_POST['sugar']) . "'";
}
if (isset($_POST['albumin'])) {
$optional_params .= ", albumin='" . addslashes($_POST['albumin']) . "'";
}
if ($health_advices != '' && $health_advices != null) {
$optional_params .= ", health_advices='" . addslashes($health_advices) . "' ";
}
if ($health_risks != '' && $health_risks != null) {
$optional_params .= ", health_risks='" . addslashes($health_risks) . "' ";
}
if (isset($_POST['p'])) {
$optional_params .= ", p='" . addslashes($_POST['p']) . "' ";
}
if (isset($_POST['cy'])) {
$optional_params .= ", cy='" . addslashes($_POST['cy']) . "' ";
}
if (isset($_POST['i'])) {
$optional_params .= ", i='" . addslashes($_POST['i']) . "' ";
}
if (isset($_POST['cl'])) {
$optional_params .= ", cl='" . addslashes($_POST['cl']) . "' ";
}
if (isset($_POST['e'])) {
$optional_params .= ", e='" . addslashes($_POST['e']) . "' ";
}
if (isset($_POST['audio_findings_left'])) {
$optional_params .= ", audio_findings_left='" . addslashes($_POST['audio_findings_left']) . "' ";
}
if (isset($_POST['audio_findings_right'])) {
$optional_params .= ", audio_findings_right='" . addslashes($_POST['audio_findings_right']) . "' ";
}
if (isset($_POST['urine_findings'])) {
$optional_params .= ", urine_findings='" . addslashes($_POST['urine_findings']) . "' ";
}
if (isset($_POST['typhoid_findings'])) {
$optional_params .= ", typhoid_findings='" . addslashes($_POST['typhoid_findings']) . "' ";
}
if (isset($_POST['lft_findings'])) {
$optional_params .= ", lft_findings='" . addslashes($_POST['lft_findings']) . "' ";
}
if (isset($_POST['ear'])) {
$optional_params .= ", ear='" . addslashes($_POST['ear']) . "' ";
}
if (isset($_POST['deformities'])) {
$optional_params .= ", deformities='" . addslashes($_POST['deformities']) . "' ";
}
if (isset($_POST['xray_findings'])) {
$optional_params .= ", xray_findings='" . addslashes($_POST['xray_findings']) . "' ";
}
if (isset($_POST['sputum_findings'])) {
$optional_params .= ", sputum_findings='" . addslashes($_POST['sputum_findings']) . "' ";
}
if (isset($_POST['ft3'])) {
$optional_params .= ", ft3='" . addslashes($_POST['ft3']) . "' ";
}
if (isset($_POST['ft4'])) {
$optional_params .= ", ft4='" . addslashes($_POST['ft4']) . "' ";
}
if (isset($_POST['tsh'])) {
$optional_params .= ", tsh='" . addslashes($_POST['tsh']) . "' ";
}
if (isset($_POST['bn_findings'])) {
$optional_params .= ", bn_findings='" . addslashes($_POST['bn_findings']) . "' ";
}
if (isset($_POST['a'])) {
$optional_params .= ", a='" . addslashes($_POST['a']) . "' ";
}
if (isset($_POST['oe'])) {
$optional_params .= ", oe='" . addslashes($_POST['oe']) . "' ";
}
if (isset($_POST['pr'])) {
$optional_params .= ", pr='" . addslashes($_POST['pr']) . "' ";
}
if (isset($_POST['p_abd'])) {
$optional_params .= ", p_abd='" . addslashes($_POST['p_abd']) . "' ";
}
if (isset($_POST['chest'])) {
$optional_params .= ", chest='" . addslashes($_POST['chest']) . "' ";
}
if (isset($_POST['dress'])) {
$optional_params .= ", dress='" . addslashes($_POST['dress']) . "' ";
}
if (isset($_POST['other_diseases'])) {
$optional_params .= ", other_diseases='" . addslashes($_POST['other_diseases']) . "' ";
}
if (isset($_POST['rd_dsph'])) {
$optional_params .= ", rd_dsph='" . addslashes($_POST['rd_dsph']) . "' ";
}
if (isset($_POST['rd_dcyl'])) {
$optional_params .= ", rd_dcyl='" . addslashes($_POST['rd_dcyl']) . "' ";
}
if (isset($_POST['rd_axis'])) {
$optional_params .= ", rd_axis='" . addslashes($_POST['rd_axis']) . "' ";
}
if (isset($_POST['rd_v'])) {
$optional_params .= ", rd_v='" . addslashes($_POST['rd_v']) . "' ";
}
if (isset($_POST['ld_dsph'])) {
$optional_params .= ", ld_dsph='" . addslashes($_POST['ld_dsph']) . "' ";
}
if (isset($_POST['ld_dcyl'])) {
$optional_params .= ", ld_dcyl='" . addslashes($_POST['ld_dcyl']) . "' ";
}
if (isset($_POST['ld_axis'])) {
$optional_params .= ", ld_axis='" . addslashes($_POST['ld_axis']) . "' ";
}
if (isset($_POST['ld_v'])) {
$optional_params .= ", ld_v='" . addslashes($_POST['ld_v']) . "' ";
}
if (isset($_POST['rn_dsph'])) {
$optional_params .= ", rn_dsph='" . addslashes($_POST['rn_dsph']) . "' ";
}
if (isset($_POST['rn_dcyl'])) {
$optional_params .= ", rn_dcyl='" . addslashes($_POST['rn_dcyl']) . "' ";
}
if (isset($_POST['rn_axis'])) {
$optional_params .= ", rn_axis='" . addslashes($_POST['rn_axis']) . "' ";
}
if (isset($_POST['rn_v'])) {
$optional_params .= ", rn_v='" . addslashes($_POST['rn_v']) . "' ";
}
if (isset($_POST['ln_dsph'])) {
$optional_params .= ", ln_dsph='" . addslashes($_POST['ln_dsph']) . "' ";
}
if (isset($_POST['ln_dcyl'])) {
$optional_params .= ", ln_dcyl='" . addslashes($_POST['ln_dcyl']) . "' ";
}
if (isset($_POST['ln_axis'])) {
$optional_params .= ", ln_axis='" . addslashes($_POST['ln_axis']) . "' ";
}
if (isset($_POST['ln_v'])) {
$optional_params .= ", ln_v='" . addslashes($_POST['ln_v']) . "' ";
}
if (isset($_POST['health_index'])) {
$optional_params .= ", health_index='" . addslashes($_POST['health_index']) . "' ";
}
if (isset($_POST['chest_in'])) {
$optional_params .= ", chest_in='" . addslashes($_POST['chest_in']) . "' ";
}
if (isset($_POST['chest_exp'])) {
$optional_params .= ", chest_exp='" . addslashes($_POST['chest_exp']) . "' ";
}
if (isset($_POST['cnc'])) {
$optional_params .= ", cold_cough='" . addslashes($_POST['cnc']) . "' ";
}
if (isset($_POST['gw'])) {
$optional_params .= ", general_weakness='" . addslashes($_POST['gw']) . "' ";
}
if (isset($_POST['smell'])) {
$optional_params .= ", smell='" . addslashes($_POST['smell']) . "' ";
}
if (isset($_POST['sodium'])) {
$optional_params .= ", sodium='" . addslashes($_POST['sodium']) . "' ";
}
if (isset($_POST['potassium'])) {
$optional_params .= ", potassium='" . addslashes($_POST['potassium']) . "' ";
}
if (isset($_POST['rft_phosphate'])) {
$optional_params .= ", rft_phosphate='" . addslashes($_POST['rft_phosphate']) . "' ";
}
if (isset($_POST['hco3'])) {
$optional_params .= ", hco3='" . addslashes($_POST['hco3']) . "' ";
}
if (isset($_POST['quantity'])) {
$optional_params .= ", quantity='" . addslashes($_POST['quantity']) . "' ";
}
if (isset($_POST['colour'])) {
$optional_params .= ", colour='" . addslashes($_POST['colour']) . "' ";
}
if (isset($_POST['spec_grav'])) {
$optional_params .= ", spec_grav='" . addslashes($_POST['spec_grav']) . "' ";
}
if (isset($_POST['ph'])) {
$optional_params .= ", ph='" . addslashes($_POST['ph']) . "' ";
}
if (isset($_POST['chyle'])) {
$optional_params .= ", chyle='" . addslashes($_POST['chyle']) . "' ";
}
if (isset($_POST['ketone_body'])) {
$optional_params .= ", ketone_body='" . addslashes($_POST['ketone_body']) . "' ";
}
if (isset($_POST['blood'])) {
$optional_params .= ", blood='" . addslashes($_POST['blood']) . "' ";
}
if (isset($_POST['glucose'])) {
$optional_params .= ", glucose='" . addslashes($_POST['glucose']) . "' ";
}
if (isset($_POST['protein'])) {
$optional_params .= ", protein='" . addslashes($_POST['protein']) . "' ";
}
if (isset($_POST['leu_est'])) {
$optional_params .= ", leucocytes_esterase='" . addslashes($_POST['leu_est']) . "' ";
}
if (isset($_POST['bile_pigment'])) {
$optional_params .= ", bile_pigment='" . addslashes($_POST['bile_pigment']) . "' ";
}
if (isset($_POST['phosphates'])) {
$optional_params .= ", phosphates='" . addslashes($_POST['phosphates']) . "' ";
}
if (isset($_POST['urobilinogen'])) {
$optional_params .= ", urobilinogen='" . addslashes($_POST['urobilinogen']) . "' ";
}
if (isset($_POST['bacteria'])) {
$optional_params .= ", bacteria='" . addslashes($_POST['bacteria']) . "' ";
}
if (isset($_POST['cellular'])) {
$optional_params .= ", cellular='" . addslashes($_POST['cellular']) . "' ";
}
if (isset($_POST['hyaline'])) {
$optional_params .= ", hyaline='" . addslashes($_POST['hyaline']) . "' ";
}
if (isset($_POST['fatty'])) {
$optional_params .= ", fatty='" . addslashes($_POST['fatty']) . "' ";
}
if (isset($_POST['granular'])) {
$optional_params .= ", granular='" . addslashes($_POST['granular']) . "' ";
}
if (isset($_POST['calc_ox'])) {
$optional_params .= ", calcium_oxalate='" . addslashes($_POST['calc_ox']) . "' ";
}
if (isset($_POST['tripple_phosphates'])) {
$optional_params .= ", tripple_phosphates='" . addslashes($_POST['tripple_phosphates']) . "' ";
}
if (isset($_POST['amorphous_phosphates'])) {
$optional_params .= ", amorphous_phosphates='" . addslashes($_POST['amorphous_phosphates']) . "' ";
}
if (isset($_POST['others'])) {
$optional_params .= ", others='" . addslashes($_POST['others']) . "' ";
}
if (isset($_POST['cns_phosphate'])) {
$optional_params .= ", cns_phosphate='" . addslashes($_POST['cns_phosphate']) . "' ";
}
if (isset($_POST['teeth_gum'])) {
$optional_params .= ", teeth_gum='" . addslashes($_POST['teeth_gum']) . "' ";
}
if (isset($_POST['calcium'])) {
$optional_params .= ", calcium='" . addslashes($_POST['calcium']) . "' ";
}
if (isset($_POST['total_bilirubin'])) {
$optional_params .= ", total_bilirubin='" . addslashes($_POST['total_bilirubin']) . "' ";
}
if (isset($_POST['conj'])) {
$optional_params .= ", conj='" . addslashes($_POST['conj']) . "' ";
}
if (isset($_POST['unconj'])) {
$optional_params .= ", unconj='" . addslashes($_POST['unconj']) . "' ";
}
if (isset($_POST['sgop'])) {
$optional_params .= ", sgop='" . addslashes($_POST['sgop']) . "' ";
}
if (isset($_POST['sgpt'])) {
$optional_params .= ", sgpt='" . addslashes($_POST['sgpt']) . "' ";
}
if (isset($_POST['alk_phosphatase'])) {
$optional_params .= ", alk_phosphatase='" . addslashes($_POST['alk_phosphatase']) . "' ";
}
if (isset($_POST['total_protein'])) {
$optional_params .= ", total_protein='" . addslashes($_POST['total_protein']) . "' ";
}
if (isset($_POST['globulin'])) {
$optional_params .= ", globulin='" . addslashes($_POST['globulin']) . "' ";
}
if (isset($_POST['temp'])) {
$optional_params .= ", temp='" . addslashes($_POST['temp']) . "' ";
}
if (isset($_POST['spo2'])) {
$optional_params .= ", Spo2='" . addslashes($_POST['spo2']) . "' ";
}
if (isset($_POST['nitrite'])) {
$optional_params .= ", nitrite='" . addslashes($_POST['nitrite']) . "' ";
}
if (isset($_POST['bile_salt'])) {
$optional_params .= ", bile_salt='" . addslashes($_POST['bile_salt']) . "' ";
}
if (isset($_POST['remarks'])) {
$optional_params .= ", remarks='" . addslashes($_POST['remarks']) . "' ";
}
if (isset($_POST['uniconj'])) {
$optional_params .= ", uniconj='" . addslashes($_POST['uniconj']) . "' ";
}
if (isset($_POST['co'])) {
$optional_params .= ", co='" . addslashes($_POST['co']) . "' ";
}
if (isset($_POST['o_exam'])) {
$optional_params .= ", o_exam='" . addslashes($_POST['o_exam']) . "' ";
}
if (isset($_POST['prev_diagnosis'])) {
$optional_params .= ", prev_diagnosis='" . addslashes($_POST['prev_diagnosis']) . "' ";
}
if (isset($_POST['t_n_a'])) {
$optional_params .= ", t_n_a='" . addslashes($_POST['t_n_a']) . "' ";
}
if (isset($_POST['st_line_walking'])) {
$optional_params .= ", st_line_walking='" . addslashes($_POST['st_line_walking']) . "' ";
}
if (isset($_POST['tryglycerides'])) {
$optional_params .= ", triglycerides='" . addslashes($_POST['tryglycerides']) . "' ";
}
if (isset($_POST['hazard_process'])) {
$optional_params .= ", hazardous_process='" . addslashes($_POST['hazard_process']) . "' ";
}
if (isset($_POST['dangerous_operation'])) {
$optional_params .= ", dangerous_operation='" . addslashes($_POST['dangerous_operation']) . "' ";
}
if (isset($_POST['pa'])) {
$optional_params .= ", pa='" . addslashes($_POST['pa']) . "' ";
}
if (isset($_POST['hair'])) {
$optional_params .= ", hair='" . addslashes($_POST['hair']) . "' ";
}
// if(isset($_POST ['alk_phosphatase'])){
// $optional_params.=", alk_phosphatase='" . addslashes ($_POST ['alk_phosphatase'] ) . "' ";
// }
//Need remove first occurrence of , character just after set.
//$optional_params =trim($optional_params);
//$optional_params = substr($optional_params,1);
$query = $initquery . " set modified_by='" . $_SESSION['user_id'] . "', ohc_location_id='$ohc_type' " . $optional_params . $endquery;
$patient_query = "update patient_master set health_advices = '$health_advices',health_risks='$health_risks' where id='$patient_id'";
$result_patient = @mysqli_query($conn, $patient_query);
error_log("Without Approval Case Query" . $query);
} else {
//Approval Case Only
error_log("forward_status:" . $forward_status);
$asthma = 0;
$tb = 0;
$diabetes = 0;
$hbd = 0;
$epilepsy = 0;
$psychiatric = 0;
$heart_dis = 0;
$jaundice = 0;
$night_blind = 0;
$piles = 0;
$typhoid = 0;
$major_injury = 0;
$any_other_disease = 0;
$thyroid = 0;
$std = 0;
$leprosy = 0;
$smoking = 0;
$tobacco = 0;
$alcohol = 0;
$appr_doc_sign_img = "";
$approval_date = "";
$approving_doc_user_id = "";
$appr_doc_regd = "";
$appr_doc_qual = "";
$appr_doc_sign_img = "''";
$appr_doc_image_type = "";
$querypart_approval = "";
if ($forward_status == 'A' && $_SESSION['RoleCode'] == 'DOC') {
//For Doctor Approval Case
error_log("Approved Examination forward_status:" . $forward_status);
$month = date('n');
$year = date('Y');
if ($month > 3) {
$year = $year;
} else {
$year = $year - 1;
}
// $ohc_type_code=getTableFieldValue('ohc_type','ohc_code','ohc_type_id',$ohc_type);
$query_serial_no = "select max(CAST(left(serial_no,locate('/',serial_no)-1) as UNSIGNED)) from medical_examination where serial_no like '%$year%' ";
error_log("serial query:" . $query_serial_no);
$result_serial_no = @mysqli_query($conn, $query_serial_no);
$row_serial_no = mysqli_fetch_row($result_serial_no);
$serial_no = ($row_serial_no[0] + 1) . '/' . $year;
error_log("generated serial no: " . $serial_no);
$query_for_illness = "select past_present_illness from medical_examination where medical_exam_id = '" . $medical_exam_id . "' ";
error_log("illness query:" . $query_for_illness);
$result_for_illness = @mysqli_query($conn, $query_for_illness);
while ($row_for_illness = mysqli_fetch_assoc($result_for_illness)) {
$past_present_illness = $row_for_illness['past_present_illness'];
// echo $past_present_illness;
}
$temp = "";
$paramName = "";
$paramName = getCommaSeperatedValuesForInClause("select param_name from history_parameter", "param_id", $past_present_illness);
// echo "paramName:". $paramName;
$ailment_array = explode(',', $paramName);
foreach ($ailment_array as $ailment) {
if (trim($ailment) == "ASTHMA") {
$asthma = 1;
}
if (trim($ailment) == "DIABETES") {
$diabetes = 1;
}
if (trim($ailment) == "HIGH BLOOD PRESSURE") {
$hbd = 1;
}
if (trim($ailment) == "T.B") {
$tb = 1;
}
if (trim($ailment) == "EPILEPSY") {
$epilepsy = 1;
}
if (trim($ailment) == "PSYCHIATRIC ILLNESS") {
$psychiatric = 1;
}
if (trim($ailment) == "HEART DISEASE") {
$heart_dis = 1;
}
if (trim($ailment) == "NIGHT BLINDNESS") {
$night_blind = 1;
}
if (trim($ailment) == "TYPHOID") {
$typhoid = 1;
}
if (trim($ailment) == "MAJOR INJURY/FRACTURE/ OPERATION") {
$major_injury = 1;
}
if (trim($ailment) == "JAUNDICE") {
$jaundice = 1;
}
if (trim($ailment) == "ANY OTHER DISEASE") {
$any_other = 1;
}
if (trim($ailment) == "LEPROSY") {
$leprosy = 1;
}
if (trim($ailment) == "THYROID") {
$thyroid = 1;
}
if (trim($ailment) == "VERTIGO") {
$vertigo = 1;
}
if (trim($ailment) == "STD") {
$std = 1;
}
}
$query_for_wt = "select patient_id,waist,height,weight,bp from medical_examination where medical_exam_id = '" . $medical_exam_id . "' ";
// echo "fffffffffffff".$query_for_wt;
$result_for_wt = @mysqli_query($conn, $query_for_wt);
while ($row_for_wt = mysqli_fetch_assoc($result_for_wt)) {
$waist = $row_for_wt['waist'];
// echo $waist;
$height = $row_for_wt['height'];
// echo $height;
$weight = $row_for_wt['weight'];
// echo $weight;
$bp = $row_for_wt['bp'];
// echo $bp ;
$patient_id = $row_for_wt['patient_id'];
// echo $past_present_illness;
}
$query_for_addiction = "select addiction from patient_personal_information where medical_exam_id = '" . $medical_exam_id . "' ";
// echo $query_for_addiction;
$result_for_addiction = @mysqli_query($conn, $query_for_addiction);
// echo $result_for_addiction;
while ($row_for_addiction = mysqli_fetch_assoc($result_for_addiction)) {
$addiction = $row_for_addiction['addiction'];
}
$ailment_array1 = explode(',', $addiction);
foreach ($ailment_array1 as $ailments) {
if (trim($ailments) == "SMOKING") {
$smoking = 1;
}
if (trim($ailments) == "TOBACCO") {
$tobacco = 1;
}
if (trim($ailments) == "ALCOHOL") {
$alcohol = 1;
}
}
// $approval_date = STR_TO_DATE( $_POST ['approval_date'],'%d/%m/%Y');
$approving_doc_user_id = $_SESSION['user_id'];
$query_sign_master = "select * from employee_signature where emp_id='" . $_SESSION['logged_user_empid'] . "' ";
error_log("aprrrrrrrrrrooooooveeee" . $query_sign_master);
if (!$result_sign_master = @mysqli_query($conn, $query_sign_master)) {
error_log("Failure Pulling Doctor Signature Details" . mysqli_error($conn));
exit(mysqli_error($conn));
} else {
$row_sign_master = @mysqli_fetch_array($result_sign_master);
@extract($row_sign_master);
$appr_doc_regd = $row_sign_master['registration_no'];
$appr_doc_qual = $row_sign_master['qualification'];
$appr_doc_sign_img = "(select emp_sign from employee_signature where emp_id='" . $_SESSION['logged_user_empid'] . "' )";
error_log("aprrrrrrrrrroooooov" . $appr_doc_sign_img);
$appr_doc_image_type = $row_sign_master['image_type'];
}
$querypart_approval = ",approving_doc_qualification='" . $appr_doc_qual . "',approving_doc_regd_no='" . $appr_doc_regd . "',doc_sign_image_type='" . $appr_doc_image_type . "', approving_doc_sign_img=$appr_doc_sign_img";
if (!empty($medical_exam_id) && $forward_status == 'A') {
$query = "update medical_examination set forward_status='$forward_status' ,
asthma='$asthma',tb='$tb',diabetes='$diabetes',hbd='$hbd',epilepsy='$epilepsy',psychiatric='$psychiatric',
heart_dis='$heart_dis',night_blind='$night_blind',typhoid='$typhoid',piles='$piles',hernia='$hernia',
major_injury='$major_injury', sign_medical_officer='" . $approving_doc_user_id . "',modified_by='" . $_SESSION['user_id'] . "',
serial_no='$serial_no',addiction='$addiction',approval_date=$approval_date_str, smoking='$smoking',
tobacco='$tobacco',alcohol='$alcohol' " . $querypart_approval . " where medical_exam_id=$medical_exam_id ";
error_log("Medical Examination Approval Case Query:::" . $query);
}
}
//End Doctor Approval Case
// echo $query;
}
//Common Code to be executed.. only one db update/insert to medical_examination happens here based upon common code
if (!empty($query) && !$result = @mysqli_query($conn, $query)) {
error_log("Medical Examination Approval Failed:::" . mysqli_error($conn) . " Query:" . $query);
rollback();
exit(mysqli_error($conn));
} else {
if (empty($medical_exam_id)) {
$medical_exam_id = @mysqli_insert_id($conn);
error_log("Newly Added Medical Examination ID:" . $medical_exam_id);
}
$data['medical_exam_id'] = $medical_exam_id;
error_log("save success. Query:" . $query);
error_log("Current Medical Examination ID:" . $medical_exam_id);
//Fresh Entry case .. No forwards yet.
//if ($forward_status != 'M' && $forward_status != 'D' && $forward_status != 'A') {
error_log("Past Present Illness Saving for without forward:");
if (${"org_name0"} != null && ${"org_name0"} != "") {
mysqli_query($conn, "delete from past_occupational_history where medical_exam_id=$medical_exam_id ");
$query_patient_history_initial = "";
$query_patient_history_end = "";
$query_patient_history_final = "";
$query_patient_history_initial = "insert into past_occupational_history set medical_exam_id='$medical_exam_id' , ";
$query_patient_history_end = "";
/* } */
for ($i = 0; $i <= 1; $i++) {
if (${"org_name$i"} != null && ${"org_name$i"} != "") {
$query_patient_history_final = $query_patient_history_initial . " org_name='" . addslashes(${"org_name$i"}) . "', trade_designation='" . addslashes(${"trade_designation$i"}) . "', period_services='" . addslashes(${"period_services$i"}) . "', past_occu_illness='" . addslashes(${"past_occu_illness$i"}) . "', patient_id=" . $_REQUEST['patient_id'] . " " . $query_patient_history_end;
error_log("djfcbdskj" . $query_patient_history_final);
if (!$result_patient_history_final = @mysqli_query($conn, $query_patient_history_final)) {
error_log("Error Saving Patient past_occupational_history: Error: " . mysqli_error($conn) . " Query:" . $query_patient_history_final);
rollback();
exit(mysqli_error($conn));
}
}
}
}
if ($_POST['identi_mark'] != null && $_POST['identi_mark'] != "") {
$query_patient_personal_info_initial = "";
$query_patient_personal_info_end = "";
$query_patient_personal_info_final = "";
mysqli_query($conn, "delete from patient_personal_information where medical_exam_id='$medical_exam_id' ");
$query_patient_personal_info_initial = "insert into patient_personal_information set medical_exam_id='$medical_exam_id' ,";
$query_patient_personal_info_end = "";
$query_patient_personal_info_final = $query_patient_personal_info_initial . " identi_mark='" . addslashes($_POST['identi_mark']) . "', date_of_exam=STR_TO_DATE('" . $_POST['date_of_exam'] . "','%d/%m/%Y'), marital_status='" . addslashes($_POST['marital_status']) . "', no_of_child='" . addslashes($_POST['no_of_child']) . "', adopting_family_planning='" . addslashes($_POST['adopting_family_planning']) . "', addiction='" . addslashes(implode(',', $_POST['addiction'])) . "',family_history='" . addslashes(implode(',', $_POST['family_history'])) . "', drug_allergy='" . addslashes($_POST['drug_allergy']) . "',any_other_medication='" . addslashes($_POST['any_other_medic']) . "' " . $query_patient_personal_info_end;
error_log("cbxcfbcf" . $query_patient_personal_info_final);
if (!@mysqli_query($conn, $query_patient_personal_info_final)) {
error_log("Error Saving Patient Personal Information: Error: " . mysqli_error($conn) . " Query:" . $query_patient_personal_info_final);
rollback();
exit(mysqli_error($conn));
}
}
// /}
//}
//if Doctor Approval Case... update patient vital findings into the patient Master table also
if ($forward_status == 'A') {
if (empty($patient_id)) {
$patient_id = getFieldFromTable("patient_id", "medical_examination", "medical_exam_id", $medical_exam_id);
}
$query_for_height = "update patient_master set height='$height',weight='$weight',waist='$waist',bp='$bp',asthma='$asthma',
tb='$tb',diabetes='$diabetes',hbd='$hbd',epilepsy='$epilepsy',psychiatric='$psychiatric',heart_dis='$heart_dis',
night_blind='$night_blind',typhoid='$typhoid',major_injury='$major_injury',addiction='$addiction',smoking='$smoking',
tobacco='$tobacco',alcohol='$alcohol' where id=$patient_id ";
error_log("query for patient when approved by doctor::" . $query_for_height);
if (!@mysqli_query($conn, $query_for_height)) {
error_log("Error updating Patient Critical findings to master data: Error: " . mysqli_error($conn) . " Query:" . $query_for_height);
rollback();
exit(mysqli_error($conn));
}
} elseif (!empty($medical_exam_id) && $forward_status != 'A') {
//Non-Approval case. Simply Update approval status to medical examination other details to child tables updated above.
$query_for_status_update = "update medical_examination set forward_status='$forward_status' where medical_exam_id='$medical_exam_id' ";
error_log("query for patient when updated by Doctor or LAB but not approved::" . $query_for_height);
if (!@mysqli_query($conn, $query_for_status_update)) {
error_log("Error updating status: Error: " . mysqli_error($conn) . " Query:" . $query_for_status_update);
rollback();
exit(mysqli_error($conn));
}
}
}
// $list_color_validated_fields =
if (!empty($_POST['hiddenHighlighter'])) {
saveHighlightedParams($medical_exam_id, $_POST['hiddenHighlighter']);
}
commit();
echo json_encode($data);