396 lines
14 KiB
PHP
Executable File
396 lines
14 KiB
PHP
Executable File
<?php
|
|
|
|
if (!defined('BASEPATH'))
|
|
exit('No direct script access allowed');
|
|
|
|
class Assessment_model extends CI_model {
|
|
|
|
function __construct() {
|
|
parent::__construct();
|
|
$this->load->database();
|
|
|
|
}
|
|
|
|
function insertPatient($data) {
|
|
$this->db->insert('patient_details', $data);
|
|
return $this->db->insert_id();
|
|
}
|
|
function insertDesignate($data,$pid){
|
|
$this->db->where('id', $pid);
|
|
$this->db->update('patient_details', $data);
|
|
return 'phs2';
|
|
}
|
|
function insertServices($data,$pid){
|
|
$this->db->where('id', $pid);
|
|
$this->db->update('patient_details', $data);
|
|
return 'phs2';
|
|
}
|
|
function insertPatientInsurance($data) {
|
|
$this->db->insert('patient_insurance_info', $data);
|
|
return $this->db->insert_id();
|
|
}
|
|
/*get necessesary dropdown details*/
|
|
function getReferalSource() {
|
|
$query = $this->db->get('master_patient_ref');
|
|
return $query->result();
|
|
}
|
|
|
|
function getEleDep(){
|
|
$query = $this->db->get('master_ele_dependency');
|
|
return $query->result();
|
|
}
|
|
|
|
function getICD(){
|
|
$query = $this->db->get('master_icd');
|
|
return $query->result();
|
|
}
|
|
|
|
|
|
function getLevelService() {
|
|
$query = $this->db->get('master_level_of_service');
|
|
return $query->result();
|
|
}
|
|
|
|
function getServiceActivity() {
|
|
$query = $this->db->get('master_service_activity');
|
|
return $query->result();
|
|
}
|
|
|
|
function getTherapyType() {
|
|
$query = $this->db->get('master_therapytype');
|
|
return $query->result();
|
|
}
|
|
function getAccessType() {
|
|
$query = $this->db->get('master_access_type');
|
|
return $query->result();
|
|
}
|
|
|
|
function getTubeType() {
|
|
$query = $this->db->get('master_tubetype');
|
|
return $query->result();
|
|
}
|
|
/*get necessesary dropdown details end*/
|
|
|
|
function getWherevalue($id){
|
|
$this->db->where('id', $id);
|
|
$query = $this->db->get('patient_details');
|
|
return $query->result();
|
|
}
|
|
function getPatientById($id){
|
|
$this->db->where('id', $id);
|
|
$query = $this->db->get('patient_details');
|
|
return $query->row();
|
|
}
|
|
|
|
function saveInitialAssessment($data,$data2,$data3,$data4,$data5,$data6){
|
|
$this->db->insert('assessment', $data);
|
|
$main_id = $this->db->insert_id();
|
|
|
|
$data2['main_id'] = $main_id;
|
|
$this->db->insert('assessment_step2', $data2);
|
|
|
|
$data3['main_id'] = $main_id;
|
|
$this->db->insert('assessment_step3', $data3);
|
|
|
|
$data4['main_id'] = $main_id;
|
|
$this->db->insert('assessment_step4', $data4);
|
|
|
|
$data5['main_id'] = $main_id;
|
|
$this->db->insert('assessment_step5', $data5);
|
|
|
|
$data6['main_id'] = $main_id;
|
|
$this->db->insert('assessment_step6', $data6);
|
|
|
|
return $main_id;
|
|
}
|
|
|
|
function getWhereAssessment($id){
|
|
$this->db->select('*');
|
|
$this->db->from('assessment a1');
|
|
$this->db->join('assessment_step2 a2', 'a1.id = a2.main_id', 'left');
|
|
$this->db->join('assessment_step3 a3', 'a1.id = a3.main_id', 'left');
|
|
$this->db->join('assessment_step4 a4', 'a1.id = a4.main_id', 'left');
|
|
$this->db->join('assessment_step5 a5', 'a1.id = a5.main_id', 'left');
|
|
$this->db->join('assessment_step6 a6', 'a1.id = a6.main_id', 'left');
|
|
|
|
$this->db->where('a1.patient_id',$id);
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
}
|
|
function getAssessmentData($id){
|
|
$this->db->select('*');
|
|
$this->db->from('assessment a1');
|
|
$this->db->join('assessment_step2 a2', 'a1.id = a2.main_id', 'left');
|
|
$this->db->join('assessment_step3 a3', 'a1.id = a3.main_id', 'left');
|
|
$this->db->join('assessment_step4 a4', 'a1.id = a4.main_id', 'left');
|
|
$this->db->join('assessment_step5 a5', 'a1.id = a5.main_id', 'left');
|
|
$this->db->join('assessment_step6 a6', 'a1.id = a6.main_id', 'left');
|
|
|
|
$this->db->where('a1.schedule_id',$id);
|
|
$query = $this->db->get();
|
|
return $query->row();
|
|
}
|
|
|
|
function createAssessment($data)
|
|
{
|
|
//echo '<pre>'; print_r($data);die;
|
|
$this->db->insert("assessment", $data);
|
|
$mainId=$this->db->insert_id();
|
|
///UPDATE SCHEDULE TABLE
|
|
$this->db->where('id', $data['schedule_id']);
|
|
$this->db->update('caregiver_schedule', array('acceptance_status'=>'Reported'));
|
|
//echo $this->db->last_query();echo '<br>';
|
|
//echo $mainId;echo '<br>';
|
|
//$data = array();
|
|
//$data["patient_id"] = $patientId;
|
|
if($mainId>0){
|
|
$data=array();
|
|
$data["main_id"] = $mainId;
|
|
//echo '<pre>'; print_r($data);echo '<br>';
|
|
$this->db->insert("assessment_step2", $data);
|
|
//echo $this->db->last_query(); echo '<br>';
|
|
$this->db->insert("assessment_step3", $data);
|
|
//echo $this->db->last_query();echo '<br>';
|
|
$this->db->insert("assessment_step4", $data);
|
|
//echo $this->db->last_query();echo '<br>';
|
|
$this->db->insert("assessment_step5", $data);
|
|
//echo $this->db->last_query();echo '<br>';
|
|
$this->db->insert("assessment_step6", $data);
|
|
//echo $this->db->last_query();echo '<br>';
|
|
}
|
|
return $mainId;
|
|
}
|
|
|
|
function getCaregiverList(){
|
|
$this->db->where('verification_status','verified');
|
|
$this->db->where('status','1');
|
|
$query=$this->db->get('caregiver')->result();
|
|
return $query;
|
|
}
|
|
function saveInitialAssessmentStep($tbl, $data, $midid)
|
|
{
|
|
//echo 'TABLE NAME : '.$tbl;echo '<br>';
|
|
//echo '<pre>'; print_r($data);echo '<br>';
|
|
if($tbl=='assessment'){
|
|
$this->db->where('id', $midid);
|
|
}else{
|
|
$this->db->where('main_id', $midid);
|
|
}
|
|
$this->db->update($tbl, $data);
|
|
//echo $this->db->last_query();echo '<br>';
|
|
$effected_row=$this->db->affected_rows();
|
|
if($effected_row>0){ return true; }else{ return false; }
|
|
}
|
|
|
|
|
|
|
|
function getAssessmentType($patientId){
|
|
$query=$this->db->get_where('assessment',array('patient_id' => $patientId))->row();
|
|
if(empty($query)){
|
|
$output="initial_assessment";
|
|
}
|
|
else
|
|
{
|
|
$output="assessment";
|
|
}
|
|
return $output;
|
|
}
|
|
function main_id($id)
|
|
{
|
|
$query = $this->db->query("SELECT * FROM `assessment` where `patient_id` = '$id'");
|
|
return $query->result();
|
|
}
|
|
|
|
function getScheduleData($schedule_id){
|
|
$output=$this->db->get_where('caregiver_schedule',array('id' => $schedule_id))->row();
|
|
$data=array();
|
|
$data['date']=date("Y-m-d",strtotime($output->start));
|
|
$data['start_time']=date("H:i",strtotime($output->start));
|
|
$data['end_time']=date("H:i",strtotime($output->end));
|
|
$data['caregiver_id']=$output->caregiver_id;
|
|
return $data;
|
|
}
|
|
function getCaregiverDataByid($id){
|
|
$output=$this->db->get_where('caregiver',array('id' => $id))->row();
|
|
$output2=$this->db->get_where('master_cg_skills',array('id' => $output->qualification_type))->row();
|
|
|
|
$data=array();
|
|
$data['id']=$output->id;
|
|
$data['name']=$output->fname.' '.$output->lname;
|
|
$data['skill']=$output2->name;
|
|
//echo '<pre>'; print_r($data);die;
|
|
return $data;
|
|
}
|
|
|
|
function createReport($data)
|
|
{
|
|
//echo '<pre>'; print_r($data);die;
|
|
$this->db->insert("patient_report", $data);
|
|
$mainId=$this->db->insert_id();
|
|
$data['patient_report_id'] = $mainId;
|
|
$this->db->insert("assessment", $data);
|
|
return $mainId;
|
|
}
|
|
|
|
function savePatientReportStep($tbl, $data, $mainId, $type)
|
|
{
|
|
// echo 'TABLE NAME : '.$tbl;echo '<br>';
|
|
// echo '<pre>'; print_r($data);echo '<br>';die;
|
|
if($type == 'visit_info'){
|
|
$this->db->where('id', $mainId);
|
|
$this->db->update($tbl, array('visit_info'=>$data));
|
|
}elseif($type == 'psychosocialForm'){
|
|
$this->db->where('id', $mainId);
|
|
$this->db->update($tbl,array('psycho_social'=>$data));
|
|
}elseif($type == 'vitalSignForm'){
|
|
$this->db->where('id', $mainId);
|
|
$this->db->update($tbl, array('vital_signs'=>$data));
|
|
}elseif($type == 'NeuroRecordForm'){
|
|
$this->db->where('id', $mainId);
|
|
$this->db->update($tbl, array('neuro_eent'=>$data));
|
|
}elseif($type == 'CardiovascularForm'){
|
|
$this->db->where('id', $mainId);
|
|
$this->db->update($tbl, array('curdiovascular'=>$data));
|
|
}elseif($type == 'GIGURecordForm'){
|
|
$this->db->where('id', $mainId);
|
|
$this->db->update($tbl, array('gi_gu_reproductive'=>$data));
|
|
}elseif($type == 'MusculoskeletalForm'){
|
|
$this->db->where('id', $mainId);
|
|
$this->db->update($tbl, array('musculoskeletal_pv_pan'=>$data));
|
|
}elseif($type == 'EndrocrineForm'){
|
|
$this->db->where('id', $mainId);
|
|
$this->db->update($tbl, array('endrocrine_hemotopoietic'=>$data));
|
|
}elseif($type == 'NutritionForm'){
|
|
$this->db->where('id', $mainId);
|
|
$this->db->update($tbl, array('nutrition'=>$data));
|
|
}elseif($type == 'MedicationForm'){
|
|
$this->db->where('id', $mainId);
|
|
$this->db->update($tbl, array('medication'=>$data));
|
|
}elseif($type == 'IntegumentForm'){
|
|
$this->db->where('id', $mainId);
|
|
$this->db->update($tbl, array('integument'=>$data));
|
|
}elseif($type == 'body_mark_image'){
|
|
$this->db->where('id', $mainId);
|
|
$this->db->update($tbl, $data);
|
|
}elseif($type == 'feet_mark_image'){
|
|
$this->db->where('id', $mainId);
|
|
$this->db->update($tbl, $data);
|
|
}elseif($type == 'DMESuppliesForm'){
|
|
$this->db->where('id', $mainId);
|
|
$this->db->update($tbl, array('dme_supplies'=>$data));
|
|
}elseif($type == 'paraprofessionalForm'){
|
|
$this->db->where('id', $mainId);
|
|
$this->db->update($tbl, array('paraprofessional_supervission'=>$data));
|
|
}elseif($type == 'NarrativeForm'){
|
|
$this->db->where('id', $mainId);
|
|
$this->db->update($tbl, array('narrative'=>$data));
|
|
}elseif($type == 'AuthoritiesForm'){
|
|
$this->db->where('id', $mainId);
|
|
$this->db->update($tbl, array('authorities'=>$data));
|
|
$scheduleId=$this->getScheduleId($mainId);
|
|
if($scheduleId->schedule_id){
|
|
$this->db->where('id', $scheduleId->schedule_id);
|
|
$this->db->update('caregiver_schedule', array('acceptance_status'=>'Reported'));
|
|
}
|
|
|
|
}elseif($type == 'intake_sheet'){
|
|
$this->db->where('id', $mainId);
|
|
$this->db->update($tbl, array('intake_sheet'=>$data));
|
|
}elseif($type == 'patientHHC_POCRecord'){
|
|
$this->db->where('id', $mainId);
|
|
$this->db->update($tbl, array('hhc_poc_record'=>$data));
|
|
}elseif($type == 'patientCovid19Screening'){
|
|
$this->db->where('id', $mainId);
|
|
$this->db->update($tbl, array('covid19screening'=>$data));
|
|
}elseif($type == 'emergency_preparedness_plan'){
|
|
$this->db->where('id', $mainId);
|
|
$this->db->update($tbl, array('emergency_preparedness_plan'=>$data));
|
|
}elseif($type == 'home_safety_assessments'){
|
|
$this->db->where('id', $mainId);
|
|
$this->db->update($tbl, array('home_safety_assessments'=>$data));
|
|
}elseif($type == 'patient_agreement'){
|
|
$this->db->where('id', $mainId);
|
|
$this->db->update($tbl, array('patient_agreement'=>$data));
|
|
}
|
|
// echo $this->db->last_query();echo '<br>';die;
|
|
$effected_row=$this->db->affected_rows();
|
|
// if($effected_row>0){
|
|
// return true;
|
|
// }else{
|
|
// return false;
|
|
// }
|
|
return true;
|
|
}
|
|
function getScheduleId($mainId){
|
|
// _die($mainId);
|
|
$this->db->select('schedule_id');
|
|
$this->db->from('patient_report');
|
|
$this->db->where('id', $mainId);
|
|
$query = $this->db->get();
|
|
return $query->row();
|
|
}
|
|
|
|
function getPatientReport($pid,$schedule_id){
|
|
$this->db->where('patient_id', $pid);
|
|
$this->db->where('schedule_id', $schedule_id);
|
|
$query = $this->db->get('patient_report');
|
|
return $query->row();
|
|
}
|
|
|
|
// for clock in out of caregiver
|
|
function checkForClickInOut($schedule_id)
|
|
{
|
|
$this->db->where('schedule_id',$schedule_id);
|
|
$query=$this->db->get('caregiver_patient_clock_in_out');
|
|
if($query->row()){
|
|
return $query->row();
|
|
}else{
|
|
return 0;
|
|
}
|
|
}
|
|
function insert_clock_in_info($data)
|
|
{
|
|
$this->db->where('schedule_id', $data['schedule_id']);
|
|
$query=$this->db->get('caregiver_patient_clock_in_out');
|
|
if($query->row()){
|
|
return false;
|
|
}else{
|
|
$query=$this->db->insert('caregiver_patient_clock_in_out', $data);
|
|
if($query){
|
|
return true;
|
|
}else{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
}
|
|
function update_clock_out_info($data)
|
|
{
|
|
$this->db->where('schedule_id', $data['schedule_id']);
|
|
$query=$this->db->update('caregiver_patient_clock_in_out', $data);
|
|
if($this->db->affected_rows() > 0){
|
|
return TRUE;
|
|
}else{
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
function check_visit_info($pid,$schedule_id){
|
|
$this->db->select("visit_info");
|
|
$this->db->where("patient_id",$pid);
|
|
$this->db->where("schedule_id",$schedule_id);
|
|
$this->db->from("patient_report");
|
|
$query = $this->db->get()->row();
|
|
return $query;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/* for data table end */
|
|
|
|
|
|
|
|
|
|
|