load->model('Patient_model'); if (!$this->ion_auth->in_group(array('admin','Caregiver'))) { if(!$this->ion_auth->coordinator_permission('coordinators')) redirect('home/permission'); } // if (!$this->ion_auth->in_group(array('admin'))) { // if(!$this->ion_auth->coordinator_permission('coordinators')) // redirect('home/permission'); // } $this->load->model('Assessment_model'); $this->debug=true; } public function index() { // echo "hii";exit; //$data['nurses'] = $this->nurse_model->getNurse(); $this->load->helper('dynamicFormViewer'); // viewDynamincForm(); // die; $id=$this->input->get('id'); $schedule_id=$this->input->get('scheduleId'); // this is for clock in & out // $data['clock_InOut']=$this->Assessment_model->checkForClickInOut($schedule_id); // this is for clock in & out $data['type']=$this->Assessment_model->getAssessmentType($id); $data['therapyType'] = $this->Assessment_model->getTherapyType(); $data['patient_data']=$this->Assessment_model->getPatientById($id); $data['schedule_id']=$schedule_id; $data['schedule_data']=$this->Assessment_model->getScheduleData($schedule_id); $caregiver_id=$data['schedule_data']['caregiver_id']; $data['caregiver']=$this->Assessment_model->getCaregiverDataByid($caregiver_id); $data['heading']='NEW ASSESSMENT'; $data['reportData'] = $this->Assessment_model->getPatientReport($id,$schedule_id); // _die($data['reportData']); // $data['heading']='VIEW/EDIT ASSESSMENT'; // $newArray=[]; $array1=[]; $array2=[]; $array3=[]; $array4=[]; $array5=[]; $array6=[]; $array7=[]; $array8=[]; $array9=[]; $array10=[]; $array11=[]; $array12=[]; if($data['reportData']->visit_info){ $obj=json_decode($data['reportData']->visit_info); $array1=$this->objectToArray($obj); } if($data['reportData']->vital_signs){ $obj2=json_decode($data['reportData']->vital_signs); $array2=$this->objectToArray($obj2); } if($data['reportData']->neuro_eent){ $array3=$this->objectToArray(json_decode($data['reportData']->neuro_eent)); } if($data['reportData']->curdiovascular){ $array4=$this->objectToArray(json_decode($data['reportData']->curdiovascular)); } if($data['reportData']->gi_gu_reproductive){ $array5=$this->objectToArray(json_decode($data['reportData']->gi_gu_reproductive)); } if($data['reportData']->musculoskeletal_pv_pan){ $array6=$this->objectToArray(json_decode($data['reportData']->musculoskeletal_pv_pan)); } if($data['reportData']->endrocrine_hemotopoietic){ $array7=$this->objectToArray(json_decode($data['reportData']->endrocrine_hemotopoietic)); } if($data['reportData']->nutrition){ $array8=$this->objectToArray(json_decode($data['reportData']->nutrition)); } if($data['reportData']->integument){ $array9=$this->objectToArray(json_decode($data['reportData']->integument)); } if($data['reportData']->dme_supplies){ $array10=$this->objectToArray(json_decode($data['reportData']->dme_supplies)); } if($data['reportData']->paraprofessional_supervission){ $array11=$this->objectToArray(json_decode($data['reportData']->paraprofessional_supervission)); } if($data['reportData']->narrative){ $array12=$this->objectToArray(json_decode($data['reportData']->narrative)); } $data['newArray']=json_encode(array_merge($array1,$array2,$array3,$array4,$array5,$array6,$array7,$array8,$array9,$array10,$array11,$array12)); // pre($data);die(); // pre($data['clock_InOut']);die(); // echo '
'; print_r($data['caregiver']);die;
        $this->load->view('home/dashboard'); // just the header file
        $this->load->view('home/new_assessment',$data);
        $this->load->view('home/footer'); // just the header file
        $this->load->view('home/dynamicViewScript',$data['newArray']); 
    }

    #caregiver clock in out
    public function ajax_clock_in()
    {
        $data['caregiver_id']=$_GET['cg_id'];
        $data['patient_id']=$_GET['pt_id'];
        $data['schedule_id']=$_GET['sch_id'];
        $data['clock_in_time']=gmdate("Y-m-d H:i:s");
        $geoaddress=$this->ipgeoAddress();
        $timeZone=$geoaddress->timezone;
        $clockInData=array(
                            "ip"=>$geoaddress->ip,
                            "latitute"=>$geoaddress->latitude,
                            "longitude"=>$geoaddress->longitude,
                            "city"=>$geoaddress->city,
                            "zipcode"=>$geoaddress->zipcode,
                            "time_zone"=>$geoaddress->time_zone,
                            "country_flag"=>$geoaddress->country_flag
                        );
        $data['clock_in_data']=json_encode($clockInData);
        $data['status']="1";
        $data['created_on']=gmdate("Y-m-d H:i:s");

        // $data['clock_status']="0";
        // $date=gmdate("Y-m-d H:i:s");
        // $data['clock_in_time']=time();
        // echo strtotime($date);
        // $time=time();
        // $date=date("Y-m-d H:s:i");
        // echo $time;
        $result=$this->Assessment_model->insert_clock_in_info($data);
        if($result){
            echo "1";
        }else{
            echo "0";
        }  
    }
    public function ajax_clock_out()
    {
        $data['schedule_id']=$_GET['sch_id'];
        $data['clock_out_time']=gmdate("Y-m-d H:i:s");
        $geoaddress=$this->ipgeoAddress();
        $timeZone=$geoaddress->timezone;
        $clockOutData=array(
                            "ip"=>$geoaddress->ip,
                            "latitute"=>$geoaddress->latitude,
                            "longitude"=>$geoaddress->longitude,
                            "city"=>$geoaddress->city,
                            "zipcode"=>$geoaddress->zipcode,
                            "time_zone"=>$geoaddress->time_zone,
                            "country_flag"=>$geoaddress->country_flag
                        );
        $data['clock_out_data']=json_encode($clockOutData);
        $data['clock_status']="1";
        $result=$this->Assessment_model->update_clock_out_info($data);
        if($result){
            echo "1";
        }else{
            echo "0";
        }   
    }
    public function ipgeoAddress($ip=NULL){
        $res=$this->ipgeoAddressAPI($ip);
        return $res;
    }
    public function ipgeoAddressAPI($ip=NULL){
        $apiKey = '7cba03079a814ebcbd04059e7830e2fa';
        if($ip){
            $url = "https://api.ipgeolocation.io/ipgeo?apiKey=".$apiKey."&ip=".$ip;
        }else{
		    $url = "https://api.ipgeolocation.io/ipgeo?apiKey=".$apiKey."";
        }
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		$responseJson = curl_exec($ch);
		curl_close($ch);
        $response = json_decode($responseJson);
        return $response;
    }
    #caregiver clock in out


    public function saveAssessment()
    {
        //echo '
'; print_r($_POST); echo '
';die; // $_GET['pid'] = rand(1111,9999); $data = array( 'date' => $this->input->post('pvrDate'), 'day' => $this->input->post('pvrDay'), 'timeIn' => $this->input->post('pvrTimeIn'), 'timeOut' => $this->input->post('pvrTimeOut'), 'patientName' => $this->input->post('patientName'), 'dob' => $this->input->post('dob'), 'diagonosis' => $this->input->post('pvrDiagnosis'), 'allergy' => $this->input->post('pvrAllergy'), 'md_name' => $this->input->post('pvrMd'), 'md_contactInfo' => $this->input->post('pvrMdcntInfo'), 'id_confirmed' => $this->input->post('ID_confirmed'), 'Reason' => $this->input->post('pvrReason'), 'type_of_therapy' => $this->input->post('therapy_type'), 'type_of_therapy_value' => $this->input->post('therapy_type'), 'visit_activity' => $this->input->post('pvrVisitActivity'), 'types_of_device_access' => $this->input->post('PVRtypesOfDeviceAccess'), 'accessAssessment' => $this->input->post('accessAssessmentDD'), 'action' => $this->input->post('action') ); $data['patient_id'] = $_GET['id']; $data2 = array( 'pump_bettery_change' => $this->input->post('pumpBetteryCharge'), 'pump_res_volume' => $this->input->post('pumpRexVolume'), 'pump_infusion_volume' => $this->input->post('pumpInfusionVolume'), 'pump_rate' => $this->input->post('pumpRate'), 'bolus' => $this->input->post('pvrBolus'), 'KVO' => $this->input->post('pvrKVO'), 'taper' => $this->input->post('pvrTaper'), 'program_verified_with' => $this->input->post('Program_Verified_With'), //PHYSICAL ASSESSMENT 'vital_signs' => $this->input->post('phyAssVitalSign'), 'vital_signs_measurment' => $this->input->post('vital_Sign_measurement'), 'cardiovascular' => $this->input->post('cardiovascular'), 'cardiovacularNotes' => $this->input->post('cvacNotes'), 'RESPIRATORY' => $this->input->post('respiratory'), 'respiratory_notes' => $this->input->post('respNotes'), // Food fluides 'foods' => $this->input->post('foodDiet'), 'fluid' => $this->input->post('fluidDiet'), 'fluid_intake' => $this->input->post('fluidIntake'), 'weight' => $this->input->post('WeightAmount'), 'WeightGainType' => $this->input->post('WeightGainType'), 'fl_comments' => $this->input->post('WeightComments'), //ENDOCRINE 'diabetes' => $this->input->post('Diabetes'), 'blood_suger' => $this->input->post('bloodSugarMeasure'), 'musculosketal' => $this->input->post('Musculosketal'), 'mus_activity' => $this->input->post('MusculosketalActivity'), 'ambulatory' => $this->input->post('ambulatoryAr'), 'dependent' => $this->input->post('DependentAR'), 'wheelChair' => $this->input->post('wheelChairAR'), 'arComment' => $this->input->post('CommentsAR'), //pain 'pain_level_assessed' => $this->input->post('painLevelAssessed'), 'pla_type' => $this->input->post('painType'), 'relief_from' => $this->input->post('ReliefFrom'), //Skin 'skin' => $this->input->post('skin'), 'sk_describe' => $this->input->post('skinDescribe'), 'bruises_location' => $this->input->post('skinBruisesLocation'), 'surgikal_site' => $this->input->post('skinsurgicalsite'), 'wound' => $this->input->post('skinWonds'), 'woundcomment' => $this->input->post('skinComments') ); $data3 = array( //CIRCULATION 'circulation' => $this->input->post('circCheastPain'), 'edema' => $this->input->post('circEdema'), 'edema_location' => $this->input->post('circLocation'), 'peripheral_capilary_refil' => $this->input->post('peripheralCapilaryRefill'), 'circulation_status' => $this->input->post('CirculationStatus'), 'circulationStat_comment' => $this->input->post('Circulation_Comments'), //VENTILATION 'ventilator_type' => $this->input->post('ventilatorType'), 'breathSound' => $this->input->post('BreathSounds'), 'sob' => $this->input->post('ventilator_sob'), 'color ' => $this->input->post('ventilatorColor'), 'ventilator_setting' => $this->input->post('ventilatorSetting'), 'ventilator_mode' => $this->input->post('ventilatorMode'), 'ventilatortv' => $this->input->post('ventilatorTv'), 'ventilatorPressure' => $this->input->post('ventilatorPressure'), 'ventilatorBR' => $this->input->post('ventilatorBR'), 'ventilatorOxygenMeasure' => $this->input->post('ventilatorOxygenMeasure'), 'inspiratory_time' => $this->input->post('ventilatorInspiratoryTime'), 'oxymeterFrequencyNote' => $this->input->post('OximeterFrequency'), 'oxymeterParameterNotes' => $this->input->post('oximeterParameter'), 'oxOtherNotes' => $this->input->post('ventilatorOtherNote'), 'ventDependent' => $this->input->post('ventDependent'), 'ventComment' => $this->input->post('ventilatorComments'), //TRACHEOTOMY CARE 'tracheotomy_care_required' => $this->input->post('TracheotomyCareRequired'), //MD Orders 'mdOrders' => $this->input->post('MdOrderNotes'), 'trachExcorition' => $this->input->post('MDTrachExcoriation'), 'teNotes' => $this->input->post('MDTrachExcoriationNotes'), 'TrachDrainage' => $this->input->post('MDTrachDrainage'), 'TrachDrainageNotes' => $this->input->post('MDTrachDrainageNotes'), 'rednessAtTrachSite' => $this->input->post('MDTrachDrainageNotes'), 'ratsNotes' => $this->input->post('MDTrachDrainageNotes'), 'trachInnerCannualChange' => $this->input->post('MDTrachInnerCannulaChanged'), 'ticcNotes' => $this->input->post('MDTrachInnerCannulaChangedMdOrderNotes'), 'trachConnectorSize' => $this->input->post('MDtrachConnectorSize'), 'trachConnectorlength' => $this->input->post('MDtrachConnectorLength'), 'trachSuction' => $this->input->post('MDtrachSuction'), 'tsNotes' => $this->input->post('MDTrachSuctionnotes'), 'trachSuctionType' => $this->input->post('MDtrachSuctionType'), 'trachSuctionCatheterKit' => $this->input->post('MDtrachSuctionCatherKit'), 'trachSuctionCatheterKitsize' => $this->input->post('MDtrachCAthertarKitSize'), 'trachSuctionNotes' => $this->input->post('CateterKitNotes'), //GASTROINTESTINAL 'gastrointestinal' => $this->input->post('GASTROINTESTINAL'), 'dateOflastBowelMoment' => $this->input->post('DateLastBowelMovement'), 'dlsbowComments' => $this->input->post('DateLastBowelMovementComment'), //GENITOURINARY 'genitourinary' => $this->input->post('GENITOURINARY'), 'genitourinaryColor' => $this->input->post('GENITOURINARYColor'), 'catheter' => $this->input->post('Cathertar') ); $data4 = array( 'ifindwellingComments' => $this->input->post('GENITOURINARYNotes'), //HYGINENE), 'hygineneComment' => $this->input->post('HYGINENE'), //INTEGUMENTARY 'integumentary' => $this->input->post('INTEGUMENTARY'), 'ColorVairables' => $this->input->post('INTEGUMENTARYColorVairables'), 'TemperatureVariables' => $this->input->post('INTEGUMENTARYTemperatureVariables'), 'TurgorVariables' => $this->input->post('INTEGUMENTARYTurgorVariables'), 'TurgorVariablesComment' => $this->input->post('INTEGUMENTARYNotes'), //NERUOLOGICAL 'neuroComment' => $this->input->post('NEUROLOGICALnotes'), // PSYCHOLOGICAL / EMOTIONAL REACTION // 'neuroComment' => $this->input->post('phycholEmotionalSocialSupportSystem'), 'CopesEffectivelywithTherapy' => $this->input->post('phyEmocopesEffWithTherapy'), 'CopesEffectivelywithDieases' => $this->input->post('phyEmocopesEffWithDieases'), 'physicalEmotionalComments' => $this->input->post('NEUROLOGICALnotes'), //SKILLS - KNOWLEDGE ASSESSMENT 'skillKnowTeaching' => $this->input->post('skillKnowIncludeTeaching'), 'skillKnowComments' => $this->input->post('skillKnowIncludeTeachingnotes'), 'skillKnowLearning' => $this->input->post('skillKnowIncludeLearning'), 'skillKnowLearningComment' => $this->input->post('skillKnowIncludeLearningNotes'), //RESPONSE TO THERAPY 'adverseMedicationSideEffects' => $this->input->post('adverseMedicationSideEffects'), 'PatientComplainwithMedicationThearpy' => $this->input->post('PatientComplainwithMedicationThearpy'), 'responseTherapyComment' => $this->input->post('RESPONSETOTHERAPYnotes'), 'responseTherapyCaregiver' => $this->input->post('respTotherapyCaregiver'), 'Copes_Effectively_with_Therapy_or_Disease_process' => $this->input->post('CopesEffectivelywithTherapyorDiseaseprocess'), //MEDICATION 'MedicationChanges' => $this->input->post('MedicationChanges'), 'ReviewMedicationProfileIncludeOtc' => $this->input->post('ReviewMedicationProfileIncludeOtc'), 'NewMeds' => $this->input->post('medicationNewMeds'), 'ChangesEffectsReviewedwith' => $this->input->post('ChangesEffectsReviewedwith '), 'medicationCaregiver' => $this->input->post('medicationCaregiver'), 'useOfpump' => $this->input->post('medicationUseOfPump'), 'JobTitle' => $this->input->post('medicationJobTitle'), 'PatientIndependentInMedicationAdministration' => $this->input->post('PatientIndependentInMedicationAdministration'), 'lot' => $this->input->post('MEDICATIONlot'), 'expirationDate' => $this->input->post('MEDICATIONexpirationDate'), //EQUIPMENT 'equipment' => $this->input->post('equipment'), 'EnviornmentalSafety' => $this->input->post('equipmentEnvSafty'), 'SafetyConcerns' => $this->input->post('equipSafetyConcerns'), 'woundCare ' => $this->input->post('equipWondscare'), //MD Orders 'woundmdOrders' => $this->input->post('MDOrdersNotes'), 'WoundDate' => $this->input->post('MDOrdersWounddate'), 'siteLocationNotes' => $this->input->post('MDOrdersWoundType') ); $data5 = array( // 'woundCare' => $this->input->post('MDOrdersSiteLocation'), 'WoundDescription' => $this->input->post('MDOrdersWoundDesc'), 'WoundMeasurement' => $this->input->post('MDOrdersWoundMeasurment'), 'WoundLenghts' => $this->input->post('MDOrdersWoundLength'), 'WoundWidth' => $this->input->post('MDOrdersWoundWidth'), 'WoundDiameter' => $this->input->post('MDOrdersWoundDiameter'), 'WoundUndermining' => $this->input->post('MDOrdersWoundUndermining'), 'WoundUnderminingClockPosition' => $this->input->post('MDOrdersWoundClockPosition'), 'WoundCleanseWith' => $this->input->post('mdOrdersWondsCleasnswith'), 'WoundApplications' => $this->input->post('mdOrdersWoundApplication'), 'AppliedOther' => $this->input->post('MDOrdersAppliedOther'), 'WoundCoveredWith' => $this->input->post('mdOrdersWoundCoverdWith'), 'CoveredwithOther' => $this->input->post('MDOrdersCoverOther'), 'WoundSecuredWith' => $this->input->post('mdOrdersWoundSecureWith'), 'PackedWoundBedWith' => $this->input->post('MDOrdersPackkedWoundsWithBed'), 'WoundStatus' => $this->input->post('mdOrdersWoundStatus'), 'WoundGranulating' => $this->input->post('MDOrdersWoundsGranulating'), 'ExcroticTissuePresent' => $this->input->post('MDOrdersExcroticTissuePresent'), 'WoundEschar' => $this->input->post('MDOrdersWoundEschar'), 'NecroticTissuePresent' => $this->input->post('MDOrdersNercroticTissuePresent'), 'NecroticTissueColor' => $this->input->post('MDorderNecroticTissueColor'), 'WoundDrainage' => $this->input->post('MDOrdersWoundDrainage'), 'WoundDrainageRate' => $this->input->post('MDOrdersWoundDrainageRate'), 'WoundDrainageAmount' => $this->input->post('MDORDERWoundDrainageAmount'), 'woundBedapperance' => $this->input->post('woundBedapperance'), 'woundTunnelling' => $this->input->post('woundTunnelling'), 'woundTunnelingComment' => $this->input->post('woundTunnelingComment'), 'WoundRednessAtSite' => $this->input->post('MDOrdersWoundRednessAtSite'), 'WoundRedComments' => $this->input->post('MDOrdersWoundRednessAtSiteComment'), 'WoundOdor' => $this->input->post('MDOrdersWoundOdor'), 'WoundSwelling' => $this->input->post('MDOrdersWoundSwelling'), 'WoundSwellingComments' => $this->input->post('MDOrdersWoundSwellingComment'), 'WoundPain' => $this->input->post('MDOrdersWoundPain'), 'PatientIndependentInWoundCare' => $this->input->post('MDOrdersPatientIndependentInWoundCare'), 'PatientIsWillingToLearn' => $this->input->post('MDOrdersPatientIsWillingToLearn'), 'CaregiverIsWillingToLearn' => $this->input->post('MDOrdersCaregiverIsWillingToLearn'), 'CaregiverIsWillingToLearnComment' => $this->input->post('MDOrdersCaregiverIsWillingToLearnComment'), 'Caregiver' => $this->input->post('MdOrdersCaregiver'), //PROGRESS TOWARDS GOALS 'CarePlanDetails' => $this->input->post('PogToGoalCarePlanDetails'), 'FallPrecautions' => $this->input->post('PogToGoalFallPrecautions'), 'WeightGain' => $this->input->post('PogToGoalweightGainAmount'), 'PressureUlserRisk' => $this->input->post('PogToGoalPressureUlserRisk'), 'Constipation' => $this->input->post('PogToGoalConstipation'), ); $data6 = array( //Skilled Nursing Interventions Summary/Follow-UP Plan 'OtherCurrentServices' => $this->input->post('otherCurrentServices'), 'ReviewOfEmergencyPlan' => $this->input->post('reviewEmergencyPlan'), 'ReviewUpdateCarePlan' => $this->input->post('reviewOrupdateCarePlan'), 'FallPreventionHomeSafety' => $this->input->post('FallPreventionAndHomeSafety'), 'SeizurePrecautionsObserved' => $this->input->post('SeizurePrecautionsObserved'), 'StandardPrecautionsObserved' => $this->input->post('StandardPrecautionsObserved'), 'MaintainAspirationPrecaution' => $this->input->post('MaintainAspirationPrecaution'), 'EquipmentChecked' => $this->input->post('EquipmentCheckedNotes'), 'SuppliesInventoryChecked' => $this->input->post('SuppliesInventoryChecked'), 'SuppliesInventoryNeeded' => $this->input->post('SuppliesInventoryNeededNotes'), 'PrepourMedication' => $this->input->post('PrepourMedication'), 'OxygenSafety' => $this->input->post('OxygenSafety'), 'Supervise' => $this->input->post('SuperviseCaregiverName'), 'CareGiverTitle' => $this->input->post('CaregiverTitle'), 'cgtNotes' => $this->input->post('CaregiverTitleNotes'), 'RevisitDate' => $this->input->post('RevisitDateFlowupPlan'), //Authorities 'printName' => $this->input->post('caregiverPrintName'), 'Cltitle' => $this->input->post('caregiverPrintTitle'), 'clinicalSignature' => $this->input->post('clinicalSignature'), 'DateEntry' => $this->input->post('clinicalSignatureDate') ); if(isset($_POST['therapy_type_value'])){ $data['type_of_therapy_value'] = $this->input->post('therapy_type_value'); } if(isset($_POST['type_device_value'])){ $data['types_of_device_access_value'] = $this->input->post('type_device_value'); } if(isset($_POST['type_accAssment_value'])){ $data['accessAssessmentValue'] = $this->input->post('type_accAssment_value'); } if(isset($_POST['type_action_value'])){ $data['action_value'] = $this->input->post('type_action_value'); } if(isset($_POST['pump_rate_value'])){ $data2['pumpRateValue'] = $this->input->post('pump_rate_value'); } if(isset($_POST['CvacRhythm'])){ $data2['cardiovascular_rhythm'] = $this->input->post('CvacRhythm'); } if(isset($_POST['respBreathSound'])){ $data2['respiratory_value'] = $this->input->post('respBreathSound'); } if(isset($_POST['ENDOCRINE'])){ $data2['endoCrine'] = $this->input->post('ENDOCRINE'); } if(isset($_POST['ARprom'])){ $data2['encourage_p_rom_exa_extrimist'] = $this->input->post('ARprom'); } if(isset($_POST['painDeflict'])){ $data2['pain'] = $this->input->post('painDeflict'); } if(isset($_POST['painQuality'])){ $data2['pla_quality'] = $this->input->post('painQuality'); } if(isset($_POST['ventilationDeficit'])){ $data3['ventilation'] = $this->input->post('ventilationDeficit'); } if(isset($_POST['HYGINENEnoDeficit'])){ $data4['hyginene'] = $this->input->post('HYGINENEnoDeficit'); } if(isset($_POST['NERUOLOGICALnoDeficit'])){ $data4['neurological'] = $this->input->post('NERUOLOGICALnoDeficit'); } if(isset($_POST['neuroStatus'])){ $data4['neuroStatus'] = $this->input->post('neuroStatus'); } if(isset($_POST['NERUOLOGICALactivity'])){ $data4['neuroActivity'] = $this->input->post('NERUOLOGICALactivity'); } if(isset($_POST['phycholEmotionalSocialSupportSystem'])){ $data4['phychologicalEmotionalReaction'] = $this->input->post('phycholEmotionalSocialSupportSystem'); } if(isset($_POST['PogToGoalCArePlanReviewDisclouser'])){ $data5['carePlanReviewDisclouser'] = $this->input->post('PogToGoalCArePlanReviewDisclousers'); } $data['patient_id'] = $_GET['id']; $data2['patient_id'] = $_GET['id']; $data3['patient_id'] = $_GET['id']; $data4['patient_id'] = $_GET['id']; $data5['patient_id'] = $_GET['id']; $data6['patient_id'] = $_GET['id']; $this->load->model('Assessment_model'); $this->Assessment_model->saveInitialAssessment($data,$data2,$data3,$data4,$data5,$data6); $this->db->last_query(); redirect('initial_assessment'); } public function ajax_type_therapy(){ $type = $_POST['val']; switch ($type) { case "Other type therapy": echo ""; echo ""; break; case "Type of therapy drugs": echo ""; echo ""; break; case "Type of therapy cycle": echo ""; echo ""; break; case "Type of therapy formula": echo ""; echo ""; break; case "Reason For Visit": echo ""; echo ""; break; } } public function ajax_type_device_access() { $type = $_POST['val']; switch ($type) { case "Enteral Type": echo ""; echo ""; break; case "PICC Exposed Length": echo ""; echo ""; break; case "Number Of Lumens": echo ""; echo ""; break; } } public function ajax_type_access_assessment() { $type = $_POST['val']; switch ($type) { case "Comments": echo ""; echo ""; break; case "CARE DID NOT OCCUR": echo ""; echo ""; break; case "NON-BILLABLE VISIT": echo ""; echo ""; break; } } public function ajax_action_box() { $type = $_POST['val']; $this->load->model('Assessment_model'); $accessType = $this->Assessment_model->getAccessType(); switch ($type) { // case "N/A": // case "Injection Cap Device Change": case "Huber Device Accessed": case "Huber Device Deaccessed": case "Huber Device Flushed without Reistance": // case "Access To Vein": // case "Device Name": // case "Device Size": case "Subcutaneous Site Change": case "Subcutaneous Location": case "Subcutaneous Name": case "Subcutaneous Site": case "Pump Function Model Number": echo ""; echo ""; break; case "Lab Work Obtained": case "Peripheral Site": case "Via Central Line": echo ""; echo "
"; break; case "Dressing Change": echo ""; echo ""; break; case "Blood Return": echo ""; echo ""; break; case "Pump Function": echo ""; echo ""; break; case "Pump Function Model Number": echo ""; echo ""; break; case "Lab Sheet Tracking Sticker": case "Huber Device Type": echo ""; echo ""; break; case "Access Type": echo ""; echo ""; break; case "Flushed With 0.9% Nacl": case "Flushed With Heparin": echo "
"; break; } } public function ajax_pump_rate() { $type = $_POST['val']; switch ($type) { case "Mg": echo ""; echo ""; break; case "ml": echo ""; echo ""; break; case "times per hour": echo ""; echo ""; break; case "times daily": echo ""; echo ""; break; } } public function getPatientAssessment() { $pid = $_GET['pid']; // echo "hello"; $this->load->model('Assessment_model'); $datas = $this->Assessment_model->getWhereAssessment($pid)[0]; $mdata['data'] = $datas; $this->load->view('home/dashboard'); // just the header file $this->load->view('patientView',$mdata); // $this->load->view('home/master_assets'); $this->load->view('home/footer'); // just the header file } public function savePartData() { // echo '
';print_r($_POST); die;
        $pid = $this->input->post('pid');
        $mainId =  $this->input->post('mainId');
        if($this->input->post('scheduleId')!=""){   $schedule_id        =   $this->input->post('scheduleId'); } 
        if($this->input->post('asmType')!=""){      $assessment_type    =   $this->input->post('asmType'); } 
        //die;
        if($mainId  ==  "" && $pid  !=  "" && $schedule_id  !=  "" && $assessment_type  !=  "" )
        {
            //echo '1';
            $data = array();
            $data["patient_id"] = $pid; 
            $data["report_entry_date"]  = date("Y-m-d"); 
            $data['schedule_id']        = $schedule_id;     
            $data['assessment_type']    = $assessment_type;
            if($this->input->post('patientName')!=""){      $data['patientName']    =   $this->input->post('patientName'); }   
            if($this->input->post('dob')!=""){              $data['dob']            =   $this->input->post('dob'); }   
            if($this->input->post('caregiver_id')!=""){     $data['caregiver_id']   =   $this->input->post('caregiver_id'); }   
            // echo '
'; print_r($data);die;
            $mainId = $this->Assessment_model->createAssessment($data);  
        }  
         
        //die;
        // for assessment table
        $data = array();
        $data['patient_id'] = $pid;
        if($this->input->post('pvrDate')!=""){              $data['date']               =   $this->input->post('pvrDate');  }
        if($this->input->post('pvrTimeIn')!=""){            $data['timeIn']             =   $this->input->post('pvrTimeIn'); }
        if($this->input->post('pvrTimeOut')!=""){           $data['timeOut']            =   $this->input->post('pvrTimeOut'); }
        if($this->input->post('pvrDiagnosis')!=""){         $data['diagonosis']         =   $this->input->post('pvrDiagnosis'); }
        if($this->input->post('pvrAllergy')!=""){           $data['allergy']            =   $this->input->post('pvrAllergy'); }
        if($this->input->post('pvrMd')!=""){                $data['md_name']            =   $this->input->post('pvrMd'); }
        if($this->input->post('pvrMdcntInfo')!=""){         $data['md_contactInfo']     =   $this->input->post('pvrMdcntInfo'); }
        if($this->input->post('ID_confirmed')!=""){         $data['id_confirmed']       =   $this->input->post('ID_confirmed'); }
        if($this->input->post('pvrReason')!=""){            $data['Reason']             =   $this->input->post('pvrReason'); }
        if($this->input->post('therapy_type')!=""){         $data['type_of_therapy']    =   $this->input->post('therapy_type'); }
        //if($this->input->post('therapy_type')!=""){      $data['type_of_therapy_value'] = $this->input->post('therapy_type'); }
        if($this->input->post('pvrVisitActivity')!=""){     $data['visit_activity'] =   $this->input->post('pvrVisitActivity'); }
        if($this->input->post('PVRtypesOfDeviceAccess')!=""){ $data['types_of_device_access'] = $this->input->post('PVRtypesOfDeviceAccess'); }
        //if($this->input->post('therapy_type')!=""){      $data['types_of_device_access_value'] = $this->input->post('therapy_type'); }
        if($this->input->post('accessAssessmentDD')!=""){   $data['accessAssessment'] = $this->input->post('accessAssessmentDD'); }
        //if($this->input->post('accessAssessmentDD')!=""){ $data['accessAssessmentValue'] = $this->input->post('accessAssessmentDD'); }
        if($this->input->post('action')!=""){               $data['action'] = $this->input->post('action'); }
        //if($this->input->post('action')!=""){ $data['action_value'] = $this->input->post('action'); }
        if(!empty($data))
        {
           $success=$this->Assessment_model->saveInitialAssessmentStep('assessment',$data,$mainId);
        };
        // for assessment2 table
        $data = array();
        $data['patient_id'] = $pid;
        if($this->input->post('pumpBetteryCharge')!=""){        $data['pump_bettery_change'] = $this->input->post('pumpBetteryCharge'); }
        if($this->input->post('pumpRexVolume')!=""){            $data['pump_res_volume'] = $this->input->post('pumpRexVolume'); }
        if($this->input->post('pumpInfusionVolume')!=""){       $data['pump_infusion_volume'] = $this->input->post('pumpInfusionVolume'); }
        if($this->input->post('pumpRate')!=""){                 $data['pump_rate'] = $this->input->post('pumpRate'); }
        if($this->input->post('pump_rate_value')!=""){          $data['pumpRateValue'] = $this->input->post('pump_rate_value'); }
        if($this->input->post('pvrBolus')!=""){                 $data['bolus'] = $this->input->post('pvrBolus'); }
        if($this->input->post('pvrKVO')!=""){                   $data['KVO'] = $this->input->post('pvrKVO'); }
        if($this->input->post('pvrTaper')!=""){                 $data['taper'] = $this->input->post('pvrTaper'); }
        if($this->input->post('Program_Verified_With')!=""){    $data['program_verified_with'] = $this->input->post('Program_Verified_With'); }

        if($this->input->post('phyAssVitalSign')!=""){          $data['vital_signs'] = $this->input->post('phyAssVitalSign'); }
        if($this->input->post('vital_Sign_measurement')!=""){   $data['vital_signs_measurment'] = $this->input->post('vital_Sign_measurement'); }
        if($this->input->post('cardiovascular')!=""){           $data['cardiovascular'] = $this->input->post('cardiovascular'); }
        //if($this->input->post('Program_Verified_With')!=""){  $data['cardiovascular_rhythm'] = $this->input->post('Program_Verified_With'); }
        if($this->input->post('cvacNotes')!=""){                $data['cardiovacularNotes'] = $this->input->post('cvacNotes'); }
        if($this->input->post('respiratory')!=""){              $data['RESPIRATORY'] = $this->input->post('respiratory'); }
        if($this->input->post('respNotes')!=""){                $data['respiratory_notes'] = $this->input->post('respNotes'); }
        //if($this->input->post('Program_Verified_With')!=""){  $data['phy_ass_comments'] = $this->input->post('Program_Verified_With'); }
        if($this->input->post('foodDiet')!=""){                 $data['foods'] = $this->input->post('foodDiet'); }
        if($this->input->post('dietType')!=""){                 $data['dietType'] = $this->input->post('dietType'); }
        if($this->input->post('fluidDiet')!=""){                $data['fluid'] = $this->input->post('fluidDiet'); }
        if($this->input->post('fluidType')!=""){                $data['fluidType'] = $this->input->post('fluidType'); }
        if($this->input->post('fluidIntake')!=""){              $data['fluid_intake'] = $this->input->post('fluidIntake'); }
        if($this->input->post('WeightAmount')!=""){             $data['weight'] = $this->input->post('WeightAmount'); }
        if($this->input->post('WeightGainType')!=""){           $data['WeightGainType'] = $this->input->post('WeightGainType'); }
        if($this->input->post('WeightComments')!=""){           $data['fl_comments'] = $this->input->post('WeightComments'); }

        if($this->input->post('ENDOCRINE')!=""){                $data['endoCrine'] = $this->input->post('ENDOCRINE'); }
        if($this->input->post('Diabetes')!=""){                 $data['diabetes'] = $this->input->post('Diabetes'); }
        if($this->input->post('bloodSugarMeasure')!=""){        $data['blood_suger'] = $this->input->post('bloodSugarMeasure'); }
        if($this->input->post('DiabetesComments')!=""){         $data['bs_comments'] = $this->input->post('DiabetesComments'); }

        if($this->input->post('activity_rest')!=""){            $data['activity_rest'] = $this->input->post('activity_rest'); }
        if($this->input->post('Musculosketal')!=""){            $data['musculosketal'] = $this->input->post('Musculosketal'); }
        if($this->input->post('MusculosketalActivity')!=""){    $data['mus_activity'] = $this->input->post('MusculosketalActivity'); }
        if($this->input->post('ARprom')!=""){                   $data['encourage_p_rom_exa_extrimist'] = $this->input->post('ARprom'); }
        if($this->input->post('ambulatoryAr')!=""){             $data['ambulatory'] = $this->input->post('ambulatoryAr'); }
        if($this->input->post('DependentAR')!=""){              $data['dependent'] = $this->input->post('DependentAR'); }
        if($this->input->post('wheelChairAR')!=""){             $data['wheelChair'] = $this->input->post('wheelChairAR'); }
        if($this->input->post('CommentsAR')!=""){               $data['arComment'] = $this->input->post('CommentsAR'); }
        
        if($this->input->post('painDeflict')!=""){              $data['pain'] = $this->input->post('painDeflict'); }
        if($this->input->post('painLevelAssessed')!=""){        $data['pain_level_assessed'] = $this->input->post('painLevelAssessed'); }
        if($this->input->post('painType')!=""){                 $data['pla_type'] = $this->input->post('painType'); }
        if($this->input->post('painQuality')!=""){              $data['pla_quality'] = implode(",",$this->input->post('painQuality')); }
        if($this->input->post('ReliefFrom')!=""){               $data['relief_from'] = $this->input->post('ReliefFrom'); }

        if($this->input->post('skin')!=""){                     $data['skin'] = $this->input->post('skin'); }
        if($this->input->post('skinDescribe')!=""){             $data['sk_describe'] = $this->input->post('skinDescribe'); }
        if($this->input->post('skinBruisesLocation')!=""){      $data['bruises_location'] = $this->input->post('skinBruisesLocation'); }
        if($this->input->post('skinsurgicalsite')!=""){         $data['surgikal_site'] = $this->input->post('skinsurgicalsite'); }
        if($this->input->post('skinWonds')!=""){                $data['wound'] = $this->input->post('skinWonds'); }
        if($this->input->post('skinComments')!=""){             $data['woundcomment'] = $this->input->post('skinComments'); }
        if(!empty($data))
        {
            $success1=$this->Assessment_model->saveInitialAssessmentStep('assessment_step2',$data,$mainId);
        };

        // for assessment3 table
        $data = array();
        $data['patient_id'] = $pid;
        if($this->input->post('circulationDecifit')!=""){       $data['circulation'] = $this->input->post('circulationDecifit'); }
        if($this->input->post('circCheastPain')!=""){           $data['chest_pain_notes'] = $this->input->post('circCheastPain'); }
        if($this->input->post('circEdema')!=""){                $data['edema'] = $this->input->post('circEdema'); }
        if($this->input->post('circLocation')!=""){             $data['edema_location'] = $this->input->post('circLocation'); }
        if($this->input->post('location_check')!=""){           $data['location_check'] = $this->input->post('location_check'); }
        if($this->input->post('peripheralCapilaryRefill')!=""){ $data['peripheral_capilary_refil'] = $this->input->post('peripheralCapilaryRefill'); }
        if($this->input->post('CirculationStatus')!=""){        $data['circulation_status'] = $this->input->post('CirculationStatus'); }
        if($this->input->post('Circulation_Comments')!=""){     $data['circulationStat_comment'] = $this->input->post('Circulation_Comments'); }

        if($this->input->post('ventilationDeficit')!=""){       $data['ventilation'] = $this->input->post('ventilationDeficit'); }
        if($this->input->post('ventilatorType')!=""){           $data['ventilator_type'] = $this->input->post('ventilatorType'); }
        if($this->input->post('BreathSounds')!=""){             $data['breathSound'] = $this->input->post('BreathSounds'); }
        if($this->input->post('ventilator_sob')!=""){           $data['sob'] = $this->input->post('ventilator_sob'); }
        if($this->input->post('ventilatorColor')!=""){          $data['color'] = $this->input->post('ventilatorColor'); }
        if($this->input->post('ventilatorSetting')!=""){        $data['ventilator_setting'] = $this->input->post('ventilatorSetting'); }
        if($this->input->post('ventilatorMode')!=""){           $data['ventilator_mode'] = $this->input->post('ventilatorMode'); }
        if($this->input->post('ventilatorTv')!=""){             $data['ventilatortv'] = $this->input->post('ventilatorTv'); }
        if($this->input->post('ventilatorPressure')!=""){       $data['ventilatorPressure'] = $this->input->post('ventilatorPressure'); }
        if($this->input->post('ventilatorBR')!=""){             $data['ventilatorBR'] = $this->input->post('ventilatorBR'); }
        if($this->input->post('ventilatorOxygenMeasure')!=""){  $data['ventilatorOxygenMeasure'] = $this->input->post('ventilatorOxygenMeasure'); }
        if($this->input->post('ventilatorInspiratoryTime')!=""){$data['inspiratory_time'] = $this->input->post('ventilatorInspiratoryTime'); }
        if($this->input->post('OximeterFrequency')!=""){        $data['oxymeterFrequencyNote'] = $this->input->post('OximeterFrequency'); }
        if($this->input->post('oximeterParameter')!=""){        $data['oxymeterParameterNotes'] = $this->input->post('oximeterParameter'); }
        if($this->input->post('ventilatorOtherNote')!=""){      $data['oxOtherNotes'] = $this->input->post('ventilatorOtherNote'); }
        if($this->input->post('ventDependent')!=""){            $data['ventDependent'] = $this->input->post('ventDependent'); }
        if($this->input->post('ventilatorComments')!=""){       $data['ventComment'] = $this->input->post('ventilatorComments'); }
        
        if($this->input->post('TracheotomyCareRequired')!=""){  $data['tracheotomy_care_required'] = $this->input->post('TracheotomyCareRequired'); }
        // if($this->input->post('skinComments')!=""){             $data['mdOrders'] = $this->input->post('skinComments'); }
        // if($this->input->post('skinComments')!=""){             $data['trachExcorition'] = $this->input->post('skinComments'); }
        // if($this->input->post('skinComments')!=""){             $data['teNotes'] = $this->input->post('skinComments'); }
        // if($this->input->post('skinComments')!=""){             $data['TrachDrainage'] = $this->input->post('skinComments'); }
        // if($this->input->post('skinComments')!=""){             $data['TrachDrainageNotes'] = $this->input->post('skinComments'); }
        // if($this->input->post('skinComments')!=""){             $data['rednessAtTrachSite'] = $this->input->post('skinComments'); }
        // if($this->input->post('skinComments')!=""){             $data['ratsNotes'] = $this->input->post('skinComments'); }
        // if($this->input->post('skinComments')!=""){             $data['trachInnerCannualChange'] = $this->input->post('skinComments'); }
        // if($this->input->post('skinComments')!=""){             $data['ticcNotes'] = $this->input->post('skinComments'); }
        // if($this->input->post('skinComments')!=""){             $data['trachConnectorSize'] = $this->input->post('skinComments'); }
        // if($this->input->post('skinComments')!=""){             $data['trachConnectorlength'] = $this->input->post('skinComments'); }
        // if($this->input->post('skinComments')!=""){             $data['trachSuction'] = $this->input->post('skinComments'); }
        // if($this->input->post('skinComments')!=""){             $data['tsNotes'] = $this->input->post('skinComments'); }
        // if($this->input->post('skinComments')!=""){             $data['trachSuctionType'] = $this->input->post('skinComments'); }
        // if($this->input->post('skinComments')!=""){             $data['trachSuctionCatheterKit'] = $this->input->post('skinComments'); }
        // if($this->input->post('skinComments')!=""){             $data['trachSuctionCatheterKitsize'] = $this->input->post('skinComments'); }
        // if($this->input->post('skinComments')!=""){             $data['trachSuctionNotes'] = $this->input->post('skinComments'); }
        if($this->input->post('GASTROINTESTINALnoDeficit')!=""){   $data['GASTROINTESTINALnoDeficit'] = $this->input->post('GASTROINTESTINALnoDeficit'); }
        if($this->input->post('GASTROINTESTINAL')!=""){            $data['gastrointestinal'] = $this->input->post('GASTROINTESTINAL'); }
        if($this->input->post('DateLastBowelMovement')!=""){       $data['dateOflastBowelMoment'] = $this->input->post('DateLastBowelMovement'); }
        if($this->input->post('DateLastBowelMovementComment')!=""){$data['dlsbowComments'] = $this->input->post('DateLastBowelMovementComment'); }
        
        if($this->input->post('GENITOURINARY')!=""){               $data['genitourinary'] = $this->input->post('GENITOURINARY'); }
        if($this->input->post('GENITOURINARYColor')!=""){          $data['genitourinaryColor'] = $this->input->post('GENITOURINARYColor'); }
        if($this->input->post('Cathertar')!=""){                   $data['catheter'] = $this->input->post('Cathertar'); }
        if($this->input->post('If_Indwelling')!=""){               $data['If_Indwelling'] = $this->input->post('If_Indwelling'); }
        if($this->input->post('GENITOURINARYNotes')!=""){          $data['GENITOURINARYNotes'] = $this->input->post('GENITOURINARYNotes'); }
        if(!empty($data))
        {
            $success2=$this->Assessment_model->saveInitialAssessmentStep('assessment_step3',$data,$mainId);
        };

        // for assessment4 table
        $data = array();
        $data['patient_id'] = $pid;
        if($this->input->post('HYGINENEnoDeficit')!=""){          $data['hyginene'] = $this->input->post('HYGINENEnoDeficit'); }
        if($this->input->post('HYGINENE')!=""){                   $data['hygineneComment'] = $this->input->post('HYGINENE'); }

        if($this->input->post('INTEGUMENTARY')!=""){                   $data['integumentary'] = $this->input->post('INTEGUMENTARY'); }
        if($this->input->post('INTEGUMENTARYColorVairables')!=""){     $data['ColorVairables'] = $this->input->post('INTEGUMENTARYColorVairables'); }
        if($this->input->post('INTEGUMENTARYTemperatureVariables')!=""){ $data['TemperatureVariables'] = $this->input->post('INTEGUMENTARYTemperatureVariables'); }
        if($this->input->post('INTEGUMENTARYTurgorVariables')!=""){      $data['TurgorVariables'] = $this->input->post('INTEGUMENTARYTurgorVariables'); }
        if($this->input->post('INTEGUMENTARYNotes')!=""){                $data['TurgorVariablesComment'] = $this->input->post('INTEGUMENTARYNotes'); }
        
        if($this->input->post('NERUOLOGICALnoDeficit')!=""){      $data['neurological'] = $this->input->post('NERUOLOGICALnoDeficit'); }
        if($this->input->post('neuroStatus')!=""){                $data['neuroStatus'] = implode(",",$this->input->post('neuroStatus')); }
        if($this->input->post('NERUOLOGICALactivity')!=""){       $data['neuroActivity'] = implode(",",$this->input->post('NERUOLOGICALactivity')); }
        if($this->input->post('NEUROLOGICALnotes')!=""){          $data['neuroComment'] = $this->input->post('NEUROLOGICALnotes'); }

        if($this->input->post('phycholEmotionalNodeficit')!=""){            $data['phychologicalEmotionalReaction'] = $this->input->post('phycholEmotionalNodeficit'); }
        if($this->input->post('phycholEmotionalSocialSupportSystem')!=""){  $data['phycholEmotionalSocialSupportSystem'] = implode(",",$this->input->post('phycholEmotionalSocialSupportSystem')); }
        if($this->input->post('phyEmocopesEffWithTherapy')!=""){            $data['CopesEffectivelywithTherapy'] = $this->input->post('phyEmocopesEffWithTherapy'); }
        if($this->input->post('phyEmocopesEffWithDieases')!=""){            $data['CopesEffectivelywithDieases'] = $this->input->post('phyEmocopesEffWithDieases'); }
        
        if($this->input->post('skillKnowIncludeFamily')!=""){               $data['physicalEmotionalComments'] = $this->input->post('skillKnowIncludeFamily'); }
        if($this->input->post('skillKnowIncludeTeaching')!=""){             $data['skillKnowTeaching'] = $this->input->post('skillKnowIncludeTeaching'); }
        if($this->input->post('skillKnowIncludeTeachingnotes')!=""){        $data['skillKnowComments'] = $this->input->post('skillKnowIncludeTeachingnotes'); }
        if($this->input->post('skillKnowIncludeLearning')!=""){             $data['skillKnowLearning'] = $this->input->post('skillKnowIncludeLearning'); }
        if($this->input->post('skillKnowIncludeLearningNotes')!=""){        $data['skillKnowLearningComment'] = $this->input->post('skillKnowIncludeLearningNotes'); }

        if($this->input->post('adverseMedicationSideEffects')!=""){          $data['adverseMedicationSideEffects'] = $this->input->post('adverseMedicationSideEffects'); }
        if($this->input->post('PatientComplainwithMedicationThearpy')!=""){  $data['PatientComplainwithMedicationThearpy'] = $this->input->post('PatientComplainwithMedicationThearpy'); }
        if($this->input->post('RESPONSETOTHERAPYnotes')!=""){                $data['responseTherapyComment'] = $this->input->post('RESPONSETOTHERAPYnotes'); }
        if($this->input->post('respTotherapyCaregiver')!=""){                $data['responseTherapyCaregiver'] = $this->input->post('respTotherapyCaregiver'); }
        if($this->input->post('CopesEffectivelywithTherapyorDiseaseprocess')!=""){  $data['Copes_Effectively_with_Therapy_or_Disease_process'] = $this->input->post('CopesEffectivelywithTherapyorDiseaseprocess'); }
        
        if($this->input->post('MedicationChanges')!=""){                   $data['MedicationChanges'] = $this->input->post('MedicationChanges'); }
        if($this->input->post('ReviewMedicationProfileIncludeOtc')!=""){   $data['ReviewMedicationProfileIncludeOtc'] = $this->input->post('ReviewMedicationProfileIncludeOtc'); }
        if($this->input->post('medicationNewMeds')!=""){                   $data['NewMeds'] = $this->input->post('medicationNewMeds'); }
        if($this->input->post('ChangesEffectsReviewedwith_')!=""){         $data['ChangesEffectsReviewedwith'] = $this->input->post('ChangesEffectsReviewedwith_'); }
        if($this->input->post('medicationCaregiver')!=""){                 $data['medicationCaregiver'] = $this->input->post('medicationCaregiver'); }
        if($this->input->post('medicationUseOfPump')!=""){                 $data['useOfpump'] = $this->input->post('medicationUseOfPump'); }
        if($this->input->post('PrepourMedicationsBy')!=""){                $data['PrepourMedicationsBy'] = $this->input->post('PrepourMedicationsBy'); }
        if($this->input->post('medicationJobTitle')!=""){                  $data['JobTitle'] = $this->input->post('medicationJobTitle'); }
        if($this->input->post('PatientIndependentInMedicationAdministration')!=""){  $data['PatientIndependentInMedicationAdministration'] = $this->input->post('PatientIndependentInMedicationAdministration'); }
        if($this->input->post('MEDICATIONlot')!=""){                        $data['lot'] = $this->input->post('MEDICATIONlot'); }
        if($this->input->post('MEDICATIONexpirationDate')!=""){             $data['expirationDate'] = $this->input->post('MEDICATIONexpirationDate'); }
        
        if($this->input->post('equipment')!=""){                           $data['equipment'] = $this->input->post('equipment'); }
        if($this->input->post('equipmentEnvSafty')!=""){                   $data['EnviornmentalSafety'] = $this->input->post('equipmentEnvSafty'); }
        if($this->input->post('equipSafetyConcerns')!=""){                 $data['SafetyConcerns'] = $this->input->post('equipSafetyConcerns'); }
        if($this->input->post('equipWondscare')!=""){                      $data['woundCare'] = $this->input->post('equipWondscare'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['woundmdOrders'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundDate'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['siteLocationNotes'] = $this->input->post('HYGINENE'); }
        if(!empty($data))
        {
            $success3=$this->Assessment_model->saveInitialAssessmentStep('assessment_step4',$data,$mainId);
        };

        // for assessment5 table
        $data = array();
        $data['patient_id'] = $pid;
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundDescription'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundMeasurement'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundLenghts'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundWidth'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundDiameter'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundUndermining'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundUnderminingClockPosition'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundCleanseWith'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundApplications'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['AppliedOther'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundCoveredWith'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['CoveredwithOther'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundSecuredWith'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['PackedWoundBedWith'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundStatus'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundGranulating'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['ExcroticTissuePresent'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundEschar'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundExudate'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundSlough'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['NecroticTissuePresent'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['NecroticTissueColor'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundDrainage'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundDrainageType'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundDrainageRate'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundDrainageAmount'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['woundBedapperance'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['woundTunnelling'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['woundTunnelingComment'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundBedAppearance'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundBedComments'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundRednessAtSite'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundRedComments'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundOdor'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundOdorComments'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundSwelling'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundSwellingComments'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundPain'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['WoundPainComments'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['PatientIndependentInWoundCare'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['PatientIsWillingToLearn'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['CaregiverIsWillingToLearn'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['CaregiverIsWillingToLearnComment'] = $this->input->post('HYGINENE'); }
        // if($this->input->post('HYGINENE')!=""){                   $data['Caregiver'] = $this->input->post('HYGINENE'); }
        if($this->input->post('ProgressTowordsGoals')!=""){               $data['ptg_comments'] = $this->input->post('ProgressTowordsGoals'); }
        if($this->input->post('PogToGoalCArePlanReviewDisclouser')!=""){  $data['carePlanReviewDisclouser'] = $this->input->post('PogToGoalCArePlanReviewDisclouser'); }
        if($this->input->post('PogToGoalCarePlanDetails')!=""){           $data['CarePlanDetails'] = $this->input->post('PogToGoalCarePlanDetails'); }
        if($this->input->post('PogToGoalFallPrecautions')!=""){           $data['FallPrecautions'] = $this->input->post('PogToGoalFallPrecautions'); }
        if($this->input->post('PogToGoalweightGainAmount')!=""){          $data['WeightGain'] = $this->input->post('PogToGoalweightGainAmount'); }
        if($this->input->post('PogToGoalweightGainAmountIndays')!=""){    $data['PogToGoalweightGainAmountIndays'] = $this->input->post('PogToGoalweightGainAmountIndays'); }
        if($this->input->post('PogToGoalTemperatureMoreThan')!=""){       $data['TemperatureMoreThan'] = $this->input->post('PogToGoalTemperatureMoreThan'); }
        if($this->input->post('PogToGoalPressureUlserRisk')!=""){         $data['PressureUlserRisk'] = $this->input->post('PogToGoalPressureUlserRisk'); }
        if($this->input->post('PogToGoalConstipation')!=""){              $data['Constipation'] = $this->input->post('PogToGoalConstipation'); }
        
        if(!empty($data))
        {
            $success4=$this->Assessment_model->saveInitialAssessmentStep('assessment_step5',$data,$mainId);
        };

        // for assessment6 table
        $data = array();
        $data['patient_id'] = $pid;
        if($this->input->post('otherCurrentServices')!=""){                 $data['OtherCurrentServices'] = $this->input->post('otherCurrentServices'); }
        if($this->input->post('reviewEmergencyPlan')!=""){                  $data['ReviewOfEmergencyPlan'] = $this->input->post('reviewEmergencyPlan'); }
        if($this->input->post('reviewOrupdateCarePlan')!=""){               $data['ReviewUpdateCarePlan'] = $this->input->post('reviewOrupdateCarePlan'); }
        if($this->input->post('FallPreventionAndHomeSafety')!=""){          $data['FallPreventionHomeSafety'] = $this->input->post('FallPreventionAndHomeSafety'); }
        if($this->input->post('SeizurePrecautionsObserved')!=""){           $data['SeizurePrecautionsObserved'] = $this->input->post('SeizurePrecautionsObserved'); }
        if($this->input->post('StandardPrecautionsObserved')!=""){          $data['StandardPrecautionsObserved'] = $this->input->post('StandardPrecautionsObserved'); }
        if($this->input->post('MaintainAspirationPrecaution')!=""){         $data['MaintainAspirationPrecaution'] = $this->input->post('MaintainAspirationPrecaution'); }
        if($this->input->post('EquipmentCheckedNotes')!=""){                $data['EquipmentChecked'] = $this->input->post('EquipmentCheckedNotes'); }
        if($this->input->post('SuppliesInventoryChecked')!=""){             $data['SuppliesInventoryChecked'] = $this->input->post('SuppliesInventoryChecked'); }
        if($this->input->post('SuppliesInventoryNeededNotes')!=""){         $data['SuppliesInventoryNeeded'] = $this->input->post('SuppliesInventoryNeededNotes'); }
        if($this->input->post('PrepourMedication')!=""){                    $data['PrepourMedication'] = $this->input->post('PrepourMedication'); }
        if($this->input->post('OxygenSafety')!=""){                         $data['OxygenSafety'] = $this->input->post('OxygenSafety'); }
        if($this->input->post('SuperviseCaregiverName')!=""){               $data['Supervise'] = $this->input->post('SuperviseCaregiverName'); }
        if($this->input->post('CaregiverTitle')!=""){                       $data['CareGiverTitle'] = $this->input->post('CaregiverTitle'); }
        if($this->input->post('CaregiverTitleNotes')!=""){                  $data['cgtNotes'] = $this->input->post('CaregiverTitleNotes'); }
        if($this->input->post('RevisitDateFlowupPlan')!=""){                $data['RevisitDate'] = $this->input->post('RevisitDateFlowupPlan'); }

        if($this->input->post('caregiverPrintName')!=""){              $data['printName'] = $this->input->post('caregiverPrintName'); }
        if($this->input->post('caregiverPrintTitle')!=""){              $data['Cltitle'] = $this->input->post('caregiverPrintTitle'); }
        if($this->input->post('clinicalSignature')!=""){              $data['clinicalSignature'] = $this->input->post('clinicalSignature'); }
        if($this->input->post('clinicalSignatureDate')!=""){              $data['DateEntry'] = $this->input->post('clinicalSignatureDate'); }
        
        if(!empty($data))
        {
            $success5=$this->Assessment_model->saveInitialAssessmentStep('assessment_step6',$data,$mainId);
        };
        
        if($success ||$success1 ||$success2 ||$success3 ||$success4 ||$success5 ){
            $output['mainId']=$mainId;
            $output['msg']='Assessment data saved.';
            echo json_encode($output);
            //echo 'Assessment data saved.';
        }else{
            $output['msg']='Please fillup visit info tab.';
            echo json_encode($output);
        } 
    }


    public function saveReportData(){
        //   echo '
';print_r($_POST); die; 
        $pid = $this->input->post('pid');
        $mainId =  $this->input->post('mainId');
        $fId = $this->input->post('fId');
        if($this->input->post('scheduleId')!=""){   $schedule_id        =   $this->input->post('scheduleId'); } 
        if($this->input->post('asmType')!=""){      $assessment_type    =   $this->input->post('asmType'); } 
        //die;
        
        if($fId == 'patientVisitRecord'){
            if($mainId  ==  "" && $pid  !=  "" && $schedule_id  !=  "" && $assessment_type  !=  "" )
            {
                //echo '1';
                $data = array();
                $data["patient_id"] = $pid; 
                $data["report_entry_date"]  = date("Y-m-d"); 
                $data['schedule_id']        = $schedule_id;     
                $data['assessment_type']    = $assessment_type;  
                if($this->input->post('caregiver_id')!=""){     $data['caregiver_id']   =   $this->input->post('caregiver_id'); }   
                // echo '
'; print_r($data);die;
                $mainId = $this->Assessment_model->createReport($data);  
            } 
            // for save visit-info
            if($fId == 'patientVisitRecord'){
                $visitInfoForm = array();
                $remove = ['mainId', 'asmType','AssessmentType','scheduleId','caregiver_id','dob','patientName','signature'];
                $visitInfoForm=array_diff_key($_POST, array_flip($remove));
                
                // echo '
';print_r($visitInfoForm); die; 
                if(!empty($visitInfoForm))
                {
                    $visitInfoFormJson = json_encode($visitInfoForm);
                    // _die($visitInfoFormJson);
                    $success1=$this->Assessment_model->savePatientReportStep('patient_report',$visitInfoFormJson,$mainId,"visit_info");
                };
                if($success1){
                    $output['mainId']=$mainId;
                    $output['msg']='Assessment data saved.';
                    echo json_encode($output);
                    //echo 'Assessment data saved.';
                }else{
                    $output['msg']='Something Went Wrong.';
                    echo json_encode($output);
                }
            }
        }elseif($fId != 'patientVisitRecord'){
            // for save vital-signs
            $check_visit_info = $this->Assessment_model->check_visit_info($pid,$schedule_id);
            if($check_visit_info->visit_info){
                if($fId == 'patientPsychosocialRecord'){
                    $psychosocialForm=[];
                    $remove=['mainId','asmType','AssessmentType','scheduleId','caregiver_id','dob','patientName','signature'];
                    $psychosocialForm=array_diff_key($_POST, array_flip($remove));
                    if(!empty($psychosocialForm)){
                        $psychosocialFormJson=json_encode($psychosocialForm);
                        $success=$this->Assessment_model->savePatientReportStep('patient_report',$psychosocialFormJson,$mainId,"psychosocialForm");
                    };
                }
                if($fId == 'patientVitalSignRecord'){
                    $vitalSignForm = array();
                    $remove = ['mainId', 'asmType','AssessmentType','scheduleId','caregiver_id','dob','patientName','signature'];
                    $vitalSignForm=array_diff_key($_POST, array_flip($remove));
                    if(!empty($vitalSignForm))
                    {
                        
                        $vitalSignFormJson = json_encode($vitalSignForm);
                            $success=$this->Assessment_model->savePatientReportStep('patient_report',$vitalSignFormJson,$mainId,"vitalSignForm");
                    
                        
                    };
                }
                if($fId == 'intakeSheetRecord'){
                    $intakeForm = array();
                    $remove = ['mainId', 'asmType','AssessmentType','scheduleId','caregiver_id','dob','patientName','signature'];
                    $intakeForm=array_diff_key($_POST, array_flip($remove));
                    if(!empty($intakeForm)){
                        $intakeFormJson = json_encode($intakeForm);
                        $success=$this->Assessment_model->savePatientReportStep('patient_report',$intakeFormJson,$mainId,"intake_sheet");
                    }
                }
                if($fId == 'patientNeuroRecord'){
                    $neuroRecordForm = array();
                    $remove = ['mainId', 'asmType','AssessmentType','scheduleId','caregiver_id','dob','patientName','signature'];
                    $neuroRecordForm=array_diff_key($_POST, array_flip($remove));
                    if(!empty($neuroRecordForm))
                    {
                        $neuroRecordFormJson = json_encode($neuroRecordForm);
                        // _die($neuroRecordFormJson);
                        $success=$this->Assessment_model->savePatientReportStep('patient_report',$neuroRecordFormJson,$mainId,"NeuroRecordForm");
                    };
                }
                if($fId == 'patientCardiovascularRecord'){
                    $cardiovascularForm = array();
                    $remove = ['mainId', 'asmType','AssessmentType','scheduleId','caregiver_id','dob','patientName','signature'];
                    $cardiovascularForm=array_diff_key($_POST, array_flip($remove));
                    if(!empty($cardiovascularForm))
                    {
                        $cardiovascularFormJson = json_encode($cardiovascularForm);
                        // _die($cardiovascularFormJson);
                        $success=$this->Assessment_model->savePatientReportStep('patient_report',$cardiovascularFormJson,$mainId,"CardiovascularForm");
                    };
                }
                if($fId == 'patientGIGURecord'){
                    $gIGURecordForm = array();
                    $remove = ['mainId', 'asmType','AssessmentType','scheduleId','caregiver_id','dob','patientName','signature'];
                    $gIGURecordForm=array_diff_key($_POST, array_flip($remove));
                    if(!empty($gIGURecordForm))
                    {
                        $gIGURecordFormJson = json_encode($gIGURecordForm);
                        // _die($GIGURecordFormJson);
                        $success=$this->Assessment_model->savePatientReportStep('patient_report',$gIGURecordFormJson,$mainId,"GIGURecordForm");
                    };
                }
                if($fId == 'patientMusculoskeletalRecord'){
                    $musculoskeletalForm = array();
                    $remove = ['mainId', 'asmType','AssessmentType','scheduleId','caregiver_id','dob','patientName','signature'];
                    $musculoskeletalForm=array_diff_key($_POST, array_flip($remove));
                    if(!empty($musculoskeletalForm))
                    {
                        $musculoskeletalFormJson = json_encode($musculoskeletalForm);
                        // _die($musculoskeletalFormJson);
                        $success=$this->Assessment_model->savePatientReportStep('patient_report',$musculoskeletalFormJson,$mainId,"MusculoskeletalForm");
                    };
                }
                if($fId == 'patientEndrocrineRecord'){
                    $endrocrineForm = array();
                    $remove = ['mainId', 'asmType','AssessmentType','scheduleId','caregiver_id','dob','patientName','signature'];
                    $endrocrineForm=array_diff_key($_POST, array_flip($remove));
                    if(!empty($endrocrineForm))
                    {
                        $endrocrineFormJson = json_encode($endrocrineForm);
                        // _die($endrocrineFormJson);
                        $success=$this->Assessment_model->savePatientReportStep('patient_report',$endrocrineFormJson,$mainId,"EndrocrineForm");
                    };
                }
                if($fId == 'patientNutritionRecord'){
                    $nutritionForm = array();
                    $remove = ['mainId', 'asmType','AssessmentType','scheduleId','caregiver_id','dob','patientName','signature'];
                    $nutritionForm=array_diff_key($_POST, array_flip($remove));
                    if(!empty($nutritionForm))
                    {
                        $nutritionFormJson = json_encode($nutritionForm);
                        // _die($nutritionFormJson);
                        $success=$this->Assessment_model->savePatientReportStep('patient_report',$nutritionFormJson,$mainId,"NutritionForm");
                    };
                } 
                if($fId == 'patientMedicationRecord'){
                    $medicationForm = array();
                    $remove = ['mainId', 'asmType','AssessmentType','scheduleId','caregiver_id','dob','patientName','signature'];
                    $medicationForm=array_diff_key($_POST, array_flip($remove));
                    if(!empty($medicationForm))
                    {
                        $medicationFormJson = json_encode($medicationForm);
                        // _die($medicationFormJson);
                        $success=$this->Assessment_model->savePatientReportStep('patient_report',$medicationFormJson,$mainId,"MedicationForm");
                    };
                }
                if($fId == 'patient_agreement'){
                    $medicationForm = array();
                    $remove = ['mainId', 'asmType','AssessmentType','scheduleId','caregiver_id','dob','patientName','signature'];
                    $medicationForm=array_diff_key($_POST, array_flip($remove));
                    if(!empty($medicationForm))
                    {
                        $medicationFormJson = json_encode($medicationForm);
                        // _die($medicationFormJson);
                        $success=$this->Assessment_model->savePatientReportStep('patient_report',$medicationFormJson,$mainId,"patient_agreement");
                    };
                }
                if($fId == 'patientIntegumentRecord'){
                    if($_POST['body_mark_image'] && $_POST['body_mark_image'] != ''){
                        $body_mark_image = $_POST['body_mark_image'];
                        $ext=str_replace("data:image/","",explode(";base64,",$body_mark_image)[0]);

                        $folder_name='patient_report_'.$mainId;
                        if(!is_dir('./uploads/assessments/nurse_assessment/'.$folder_name)) {
                            mkdir('./uploads/assessments/nurse_assessment/'.$folder_name, 0777, TRUE);
                        }
                        $file_path="uploads/assessments/nurse_assessment/".$folder_name."/";
                        $filename="body_image_".$mainId.".".$ext;
                        file_put_contents($file_path.$filename, file_get_contents($body_mark_image));
                        $body_data['body_mark_image'] = $filename;
                        $body_data['body_mark_base64'] = $body_mark_image;
                        $this->Assessment_model->savePatientReportStep('patient_report',$body_data,$mainId,"body_mark_image");
                    }
                    
                    if($_POST['feet_mark_image'] && $_POST['feet_mark_image'] != ''){
                        $feet_mark_image = $_POST['feet_mark_image'];
                        $ext=str_replace("data:image/","",explode(";base64,",$feet_mark_image)[0]);

                        $folder_name='patient_report_'.$mainId;
                        if(!is_dir('./uploads/assessments/nurse_assessment/'.$folder_name)) {
                            mkdir('./uploads/assessments/nurse_assessment/'.$folder_name, 0777, TRUE);
                        }
                        $file_path="uploads/assessments/nurse_assessment/".$folder_name."/";
                        $filename="feet_image_".$mainId.".".$ext;
                        file_put_contents($file_path.$filename, file_get_contents($feet_mark_image));
                        $feet_data['feet_mark_image'] = $filename;
                        $feet_data['feet_mark_base64'] = $feet_mark_image;
                        $this->Assessment_model->savePatientReportStep('patient_report',$feet_data,$mainId,"feet_mark_image");
                    }

                    $integumentForm = array();
                    $remove = ['mainId', 'asmType','AssessmentType','scheduleId','caregiver_id','dob','patientName','signature', 'body_mark_image', 'feet_mark_image'];
                    $integumentForm=array_diff_key($_POST, array_flip($remove));
                    if(!empty($integumentForm))
                    {
                        $integumentFormJson = json_encode($integumentForm);
                        // _die($integumentFormJson);
                        $success=$this->Assessment_model->savePatientReportStep('patient_report',$integumentFormJson,$mainId,"IntegumentForm");
                    };
                }
                if($fId == 'patientDMESuppliesRecord'){
                    $DMESuppliesForm = array();
                    $remove = ['mainId', 'asmType','AssessmentType','scheduleId','caregiver_id','dob','patientName','signature'];
                    $DMESuppliesForm=array_diff_key($_POST, array_flip($remove));
                    if(!empty($DMESuppliesForm))
                    {
                        $DMESuppliesFormJson = json_encode($DMESuppliesForm);
                        // _die($DMESuppliesFormJson);
                        $success=$this->Assessment_model->savePatientReportStep('patient_report',$DMESuppliesFormJson,$mainId,"DMESuppliesForm");
                    };
                }
                if($fId == 'patientParaprofessionalRecord'){
                    $paraprofessionalForm = array();
                    $remove = ['mainId', 'asmType','AssessmentType','scheduleId','caregiver_id','dob','patientName','signature'];
                    $paraprofessionalForm=array_diff_key($_POST, array_flip($remove));
                    if(!empty($paraprofessionalForm))
                    {
                        $paraprofessionalFormJson = json_encode($paraprofessionalForm);
                        // _die($paraprofessionalFormJson);
                        $success=$this->Assessment_model->savePatientReportStep('patient_report',$paraprofessionalFormJson,$mainId,"paraprofessionalForm");
                    };
                }
                if($fId == 'patientNarrativeRecord'){
                    $narrativeForm = array();
                    $remove = ['mainId', 'asmType','AssessmentType','scheduleId','caregiver_id','dob','patientName','signature'];
                    $narrativeForm=array_diff_key($_POST, array_flip($remove));
                    if(!empty($narrativeForm))
                    {
                        $narrativeFormJson = json_encode($narrativeForm);
                        // _die($narrativeFormJson);
                        $success=$this->Assessment_model->savePatientReportStep('patient_report',$narrativeFormJson,$mainId,"NarrativeForm");
                    };
                }
                
                if($fId == 'Authorities'){
                    $authoritiesForm = array();
                    $remove = ['mainId', 'asmType','AssessmentType','caregiver_id','dob','patientName'];
                    $authoritiesForm=array_diff_key($_POST, array_flip($remove));
                    if(!empty($authoritiesForm))
                    {
                        $authoritiesFormJson = json_encode($authoritiesForm);
                        // _die($authoritiesFormJson);
                        $success=$this->Assessment_model->savePatientReportStep('patient_report',$authoritiesFormJson,$mainId,"AuthoritiesForm");
                    };
                }
                if($fId == 'patientHHC_POCRecord'){
                    $intakeForm = array();
                    $remove = ['mainId', 'asmType','AssessmentType','scheduleId','caregiver_id','dob','patientName','signature'];
                    $intakeForm=array_diff_key($_POST, array_flip($remove));
                    if(!empty($intakeForm)){
                        $intakeFormJson = json_encode($intakeForm);
                        $success=$this->Assessment_model->savePatientReportStep('patient_report',$intakeFormJson,$mainId,"patientHHC_POCRecord");
                    }
                }
                if($fId == 'patientCovid19Screening'){
                    $intakeForm = array();
                    $remove = ['mainId', 'asmType','AssessmentType','scheduleId','caregiver_id','dob','patientName','signature'];
                    $intakeForm=array_diff_key($_POST, array_flip($remove));
                    if(!empty($intakeForm)){
                        $intakeFormJson = json_encode($intakeForm);
                        $success=$this->Assessment_model->savePatientReportStep('patient_report',$intakeFormJson,$mainId,"patientCovid19Screening");
                    }
                }
                if($fId == 'emergency_preparedness_plan'){
                    $intakeForm = array();
                    $remove = ['mainId', 'asmType','AssessmentType','scheduleId','caregiver_id','dob','patientName','signature'];
                    $intakeForm=array_diff_key($_POST, array_flip($remove));
                    if(!empty($intakeForm)){
                        $intakeFormJson = json_encode($intakeForm);
                        $success=$this->Assessment_model->savePatientReportStep('patient_report',$intakeFormJson,$mainId,"emergency_preparedness_plan");
                    }
                }
                if($fId == 'home_safety_assessments'){
                    $intakeForm = array();
                    $remove = ['mainId', 'asmType','AssessmentType','scheduleId','caregiver_id','dob','patientName','signature'];
                    $intakeForm=array_diff_key($_POST, array_flip($remove));
                    if(!empty($intakeForm)){
                        $intakeFormJson = json_encode($intakeForm);
                        $success=$this->Assessment_model->savePatientReportStep('patient_report',$intakeFormJson,$mainId,"home_safety_assessments");
                    }
                }
                if($success){
                    $output['mainId']=$mainId;
                    $output['msg']='Assessment data saved.';
                    echo json_encode($output);
                    //echo 'Assessment data saved.';
                }else{
                    $output['msg']='Something Went Wrong.';
                    echo json_encode($output);
                }
            }else{
                $output['msg']='Please fill up and save Visit Info form';
                echo json_encode($output);
            }
        }   
        
    
    
    }

    public function viewReport()
    {
        $pid=$this->input->get('id');
        $schedule_id=$this->input->get('scheduleId');       
        $data['patient_data']=$this->Assessment_model->getPatientById($pid);
        // _die($data['patient_data']);
        $data['schedule_data']=$this->Assessment_model->getScheduleData($schedule_id);
        $caregiver_id=$data['schedule_data']['caregiver_id'];
        $data['caregiver']=$this->Assessment_model->getCaregiverDataByid($caregiver_id);
        /*assessment*/
        $data['reportData'] = $this->Assessment_model->getPatientReport($pid,$schedule_id);
        // _die($data['reportData']);
        /*assessment end*/

        $this->load->view('home/dashboard'); // just the header file
        $this->load->view('home/patientReportView',$data);
        $this->load->view('home/footer');
    }
    public function view(){
        // if($id==null && $schedule_id=null) redirect('approve_assessment');
        //echo '1';
        $view =$this->load->helper('dynamicFormViewer');
        // _die($view);

        $id=$this->input->get('id');
        $schedule_id=$this->input->get('scheduleId');
        // $data['id']= $id = base64_dec($id);
        // $data['scheduleId']= $schedule_id = base64_dec($schedule_id);
        $data['caregivers']=$this->Assessment_model->getCaregiverList();
        $data['type']=$this->Assessment_model->getAssessmentType($id);
        $data['therapyType'] = $this->Assessment_model->getTherapyType();
        $data['patient_data']=$this->Assessment_model->getPatientById($id);

        $data['schedule_data']=$this->Assessment_model->getScheduleData($schedule_id);
        $caregiver_id=$data['schedule_data']['caregiver_id'];
        $data['caregiver']=$this->Assessment_model->getCaregiverDataByid($caregiver_id);
        $data['ass_data']=$this->Assessment_model->getAssessmentData($schedule_id);
        $data['reportData'] = $this->Assessment_model->getPatientReport($id,$schedule_id);
        $data['heading']='VIEW/EDIT ASSESSMENT';
        // $newArray=[];
        $array_intake_sheet=[];
        $array1=[];
        $array_psycho_social=[];
        $array2=[];
        $array3=[];
        $array4=[];
        $array5=[];
        $array6=[];
        $array7=[];
        $array8=[];
        $array9=[];
        $array10=[];
        $array11=[];
        $array12=[];
        $array13=[];
        $hhc_poc_record = [];
        $covid19screening = [];
        $emergency_preparedness_plan = [];
        $home_safety_assessments = [];
        $medication = [];
        $patient_agreement = [];
        if($data['reportData']->intake_sheet){
            $array_intake_sheet=$this->objectToArray(json_decode($data['reportData']->intake_sheet));
        }
        if($data['reportData']->visit_info){
            $obj=json_decode($data['reportData']->visit_info);
            $array1=$this->objectToArray($obj);
        }
        if($data['reportData']->psycho_social){
            $obj=json_decode($data['reportData']->psycho_social);
            $array_psycho_social=$this->objectToArray($obj);
        }
        if($data['reportData']->vital_signs){
            $obj2=json_decode($data['reportData']->vital_signs);
            $array2=$this->objectToArray($obj2);
        }
        if($data['reportData']->neuro_eent){
            $array3=$this->objectToArray(json_decode($data['reportData']->neuro_eent));
        }
        if($data['reportData']->curdiovascular){
            $array4=$this->objectToArray(json_decode($data['reportData']->curdiovascular));
        }
        if($data['reportData']->gi_gu_reproductive){
            $array5=$this->objectToArray(json_decode($data['reportData']->gi_gu_reproductive));
        }
        if($data['reportData']->musculoskeletal_pv_pan){
            $array6=$this->objectToArray(json_decode($data['reportData']->musculoskeletal_pv_pan));
        }
        if($data['reportData']->endrocrine_hemotopoietic){
            $array7=$this->objectToArray(json_decode($data['reportData']->endrocrine_hemotopoietic));
        }
        if($data['reportData']->nutrition){
            $array8=$this->objectToArray(json_decode($data['reportData']->nutrition));
        }
        if($data['reportData']->integument){
            $array9=$this->objectToArray(json_decode($data['reportData']->integument));
        }
        if($data['reportData']->dme_supplies){
            $array10=$this->objectToArray(json_decode($data['reportData']->dme_supplies));
        }
        if($data['reportData']->paraprofessional_supervission){
            $array11=$this->objectToArray(json_decode($data['reportData']->paraprofessional_supervission));
        }
        if($data['reportData']->narrative){
            $array12=$this->objectToArray(json_decode($data['reportData']->narrative));
        }
        if($data['reportData']->authorities){
            $array13=$this->objectToArray(json_decode($data['reportData']->authorities));
        }
        if($data['reportData']->hhc_poc_record){
            $hhc_poc_record=$this->objectToArray(json_decode($data['reportData']->hhc_poc_record));
        }
        if($data['reportData']->covid19screening){
            $covid19screening=$this->objectToArray(json_decode($data['reportData']->covid19screening));
        }
        if($data['reportData']->emergency_preparedness_plan){
            $emergency_preparedness_plan=$this->objectToArray(json_decode($data['reportData']->emergency_preparedness_plan));
        }
        if($data['reportData']->home_safety_assessments){
            $home_safety_assessments=$this->objectToArray(json_decode($data['reportData']->home_safety_assessments));
        }
        if($data['reportData']->medication){
            $medication=$this->objectToArray(json_decode($data['reportData']->medication));
        }
        if($data['reportData']->patient_agreement){
            $patient_agreement=$this->objectToArray(json_decode($data['reportData']->patient_agreement));
        }
        $data['newArray']=json_encode(array_merge($array_intake_sheet,$array1,$array_psycho_social,$array2,$array3,$array4,$array5,$array6,$array7,$array8,$array9,$array10,$array11,$array12,$array13,$hhc_poc_record,$covid19screening,$emergency_preparedness_plan,$home_safety_assessments,$medication,$patient_agreement));
        // $json_merge = json_encode($neuro_eent);
        $this->load->view('home/dashboard'); // just the header file
        $this->load->view('home/new_assessment',$data);
        $this->load->view('home/footer'); // just the header file
        $this->load->view('home/dynamicViewScript',$data['newArray']);
        
    }

    public function objectToArray($obj){
       foreach($obj as $key=>$val){
        // echo $key.'>'.$val;
        $arr[$key]=$val;

       }
       return $arr;
    }
}

/* End of file nurse.php */
/* Location: ./application/modules/nurse/controllers/nurse.php */