diff --git a/application/controllers/Agent.php b/application/controllers/Agent.php index 8d13b083..e310ed5c 100755 --- a/application/controllers/Agent.php +++ b/application/controllers/Agent.php @@ -43,6 +43,9 @@ class Agent extends CI_Controller $data['exams'] = $this->nano_health_model->getHealthCareSheetExams($data['health_care_sheet']->id ?? null); $data['prescriptions'] = $this->nano_health_model->getHealthCareSheetPrescriptions($data['health_care_sheet']->id ?? null); + // Calcul par assuré et assurance + $data['amounts'] = $this->nano_health_model->calculateSheetAmountsParts($data['health_care_sheet']->id ?? null, $data['health_care_sheet']->type ?? null); + $this->load->view('header_agent', $data); $this->load->view('nano_health/hyper/infos_health_care_sheet'); } diff --git a/application/controllers/Hyperviseur_dash.php b/application/controllers/Hyperviseur_dash.php index f08c8555..f261c3ea 100755 --- a/application/controllers/Hyperviseur_dash.php +++ b/application/controllers/Hyperviseur_dash.php @@ -424,6 +424,8 @@ class Hyperviseur_dash extends CI_Controller $data['performances'] = $this->nano_health_model->getHealthCareSheetPerformances($data['health_care_sheet']->id ?? null); $data['exams'] = $this->nano_health_model->getHealthCareSheetExams($data['health_care_sheet']->id ?? null); $data['prescriptions'] = $this->nano_health_model->getHealthCareSheetPrescriptions($data['health_care_sheet']->id ?? null); + // Calcul par assuré et assurance + $data['amounts'] = $this->nano_health_model->calculateSheetAmountsParts($data['health_care_sheet']->id ?? null, $data['health_care_sheet']->type ?? null); $this->load->view('header_hyp', $data); $this->load->view('nano_health/hyper/infos_health_care_sheet'); diff --git a/application/language/english/message_lang.php b/application/language/english/message_lang.php index 17b250f1..0cdb76fd 100755 --- a/application/language/english/message_lang.php +++ b/application/language/english/message_lang.php @@ -639,7 +639,7 @@ $lang['provider_billing_period'] = "Provider billing period"; $lang['max_number_of_beneficiaries'] = "Maximum number of beneficiaries"; $lang['age_limit_of_child_beneficiary'] = "Age limit of child beneficiary"; $lang['support_type'] = "Type of support"; -$lang['percentage_insurer'] = "Insurer share"; +$lang['percentage_insurer'] = "Insurance share"; $lang['percentage_insured'] = "Insured share"; $lang['list_of_acts'] = "List of acts"; $lang['WEEKLY'] = "Weekly"; diff --git a/application/language/french/message_lang.php b/application/language/french/message_lang.php index 0329e53f..676c1afa 100755 --- a/application/language/french/message_lang.php +++ b/application/language/french/message_lang.php @@ -651,7 +651,7 @@ $lang['provider_billing_period'] = "Période de facturation des prestataires"; $lang['max_number_of_beneficiaries'] = "Nombre maximum d’ayants droit"; $lang['age_limit_of_child_beneficiary'] = "Age limite de l’ayant droit enfant"; $lang['support_type'] = "Type de prise en charges"; -$lang['percentage_insurer'] = "Part assureur"; +$lang['percentage_insurer'] = "Part assurance"; $lang['percentage_insured'] = "Part assuré"; $lang['list_of_acts'] = "Liste des actes"; $lang['WEEKLY'] = "Hebdomadaire"; diff --git a/application/models/Nano_health_model.php b/application/models/Nano_health_model.php index 8e246fc2..71a39f0b 100644 --- a/application/models/Nano_health_model.php +++ b/application/models/Nano_health_model.php @@ -106,4 +106,34 @@ class Nano_health_model extends CI_Model { return $this->db->get_where('nh_drugs_and_devices',['network_id'=> $networkId]); } + + public function calculateSheetAmountsParts($healthCareSheetId , $healthCareSheetType){ + $insurerAmount = 0; + $insuredAmount = 0; + + if ($healthCareSheetType == 'CONSULTATION') { + $query = $this->db->query("SELECT SUM(moderator_ticket) as moderator_ticket , SUM(insurance_amount) as insurance_amount FROM nh_performances p INNER JOIN + nh_health_care_sheets_performances hp ON p.id = hp.performance_id WHERE hp.sheet_id = $healthCareSheetId LIMIT 1"); + if ($query->num_rows() > 0) { + $insuredAmount += $query->first_row()->moderator_ticket; + $insurerAmount += $query->first_row()->insurance_amount; + } + } else { + $query = $this->db->query("SELECT SUM(insured_paid_amount) as insured_paid_amount , SUM(insurer_paid_amount) as insurer_paid_amount FROM nh_medical_prescriptions p INNER JOIN + nh_health_care_sheets_prescriptions hp ON p.id = hp.prescription_id WHERE hp.sheet_id = $healthCareSheetId LIMIT 1"); + if ($query->num_rows() > 0) { + $insuredAmount += $query->first_row()->insured_paid_amount; + $insurerAmount += $query->first_row()->insurer_paid_amount; + } + + $query = $this->db->query("SELECT SUM(insured_paid_amount) as insured_paid_amount , SUM(insurer_paid_amount) as insurer_paid_amount FROM nh_exams e INNER JOIN + nh_health_care_sheets_exams he ON e.id = he.exam_id WHERE he.sheet_id = $healthCareSheetId LIMIT 1"); + if ($query->num_rows() > 0) { + $insuredAmount += $query->first_row()->insured_paid_amount; + $insurerAmount += $query->first_row()->insurer_paid_amount; + } + } + + return [$insuredAmount, $insurerAmount]; + } } diff --git a/application/views/nano_health/hyper/infos_health_care_sheet.php b/application/views/nano_health/hyper/infos_health_care_sheet.php index f2fda9d6..4cbdd16a 100755 --- a/application/views/nano_health/hyper/infos_health_care_sheet.php +++ b/application/views/nano_health/hyper/infos_health_care_sheet.php @@ -220,6 +220,32 @@ + +
= $this->lang->line('percentage_insured') ?>
+= $this->lang->line('percentage_insurer') ?>
+