From 781939975d0a66505549de18bf3493a82dfaad55 Mon Sep 17 00:00:00 2001 From: Djery-Tom Date: Tue, 1 Feb 2022 11:58:25 +0100 Subject: [PATCH] Add care request panel in validating agent --- .../controllers/NanoHealthController.php | 131 +++------- application/controllers/ValidatingDoctor.php | 46 +++- .../controllers/pagination/CareRequests.php | 55 ++++ application/language/english/message_lang.php | 4 + application/language/french/message_lang.php | 4 + application/models/Nano_health_model.php | 12 + .../models/pagination/CareRequests_model.php | 109 ++++++++ application/views/header_agent.php | 6 +- .../hyper/infos_health_care_sheet.php | 4 +- .../validating_doctor/care_requests.php | 242 ++++++++++++++++++ .../validating_doctor/dashboard.php | 233 +++++------------ .../nano_health/validating_doctor/header.php | 4 +- 12 files changed, 580 insertions(+), 270 deletions(-) create mode 100755 application/controllers/pagination/CareRequests.php create mode 100644 application/models/pagination/CareRequests_model.php create mode 100755 application/views/nano_health/validating_doctor/care_requests.php diff --git a/application/controllers/NanoHealthController.php b/application/controllers/NanoHealthController.php index a7e00fe8..d095576c 100644 --- a/application/controllers/NanoHealthController.php +++ b/application/controllers/NanoHealthController.php @@ -346,107 +346,17 @@ class NanoHealthController extends CI_Controller public function saveHealthCareSheet($type = 'consultation') { - if($this->isLogged()) { - if (isset($_POST)) { - $url = NANO_SANTE_SERVICE_URL.'/health-care-sheets/'.$type; - $ch = curl_init($url); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); - /* set the content type json */ - curl_setopt($ch, CURLOPT_HTTPHEADER, array( - 'Content-Type:application/json', - 'Authorization:'.NANO_SANTE_SERVICE_TOKEN, - 'X-localization:'. $this->session->userdata('site_lang') == 'french' ? 'fr' : 'en' - )); - /* set return type json */ - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - $body = new \stdClass(); - foreach ($_POST as $key => $value){ - $body->{$key} = $value; - } - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); - - /* execute request */ - $result = curl_exec($ch); - /* close cURL resource */ - curl_close($ch); - - if ($result) { - echo $result; - } else { - echo json_encode(['status' => 500]); - } - } - } + echo $this->makeRequest('POST','/health-care-sheets/'.$type, $_POST); } public function updateHealthCareSheet($id) { - if($this->isLogged()) { - if (isset($_POST)) { - $url = NANO_SANTE_SERVICE_URL.'/health-care-sheets/'.$id; - $ch = curl_init($url); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); - /* set the content type json */ - curl_setopt($ch, CURLOPT_HTTPHEADER, array( - 'Content-Type:application/json', - 'Authorization:'.NANO_SANTE_SERVICE_TOKEN, - 'X-localization:'. $this->session->userdata('site_lang') == 'french' ? 'fr' : 'en' - )); - /* set return type json */ - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - $body = new \stdClass(); - foreach ($_POST as $key => $value){ - $body->{$key} = $value; - } - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); - - /* execute request */ - $result = curl_exec($ch); - /* close cURL resource */ - curl_close($ch); - - if ($result) { - echo $result; - } else { - echo json_encode(['status' => 500]); - } - } - } + echo $this->makeRequest('PUT','/health-care-sheets/'.$id, $_POST); } public function calculateHealthCareSheetPerformancesAmount() { - if($this->isLogged()) { - if (isset($_POST)) { - $url = NANO_SANTE_SERVICE_URL.'/health-care-sheets/performances-amount'; - $ch = curl_init($url); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); - /* set the content type json */ - curl_setopt($ch, CURLOPT_HTTPHEADER, array( - 'Content-Type:application/json', - 'Authorization:'.NANO_SANTE_SERVICE_TOKEN, - 'X-localization:'. $this->session->userdata('site_lang') == 'french' ? 'fr' : 'en' - )); - /* set return type json */ - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - $body = new \stdClass(); - foreach ($_POST as $key => $value){ - $body->{$key} = $value; - } - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); - - /* execute request */ - $result = curl_exec($ch); - /* close cURL resource */ - curl_close($ch); - - if ($result) { - echo $result; - } else { - echo json_encode(['status' => 500]); - } - } - } + echo $this->makeRequest('POST','/health-care-sheets/performances-amount', $_POST); } public function getHealthCareSheets() @@ -515,6 +425,41 @@ class NanoHealthController extends CI_Controller } } + public function treatCareRequest(){ + echo $this->makeRequest('PUT','/authorizations-care-requests', $_POST); + } + + private function makeRequest($method , $path , $request_body){ + if($this->isLogged()) { + $url = NANO_SANTE_SERVICE_URL.$path; + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); + /* set the content type json */ + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Content-Type:application/json', + 'Authorization:'.NANO_SANTE_SERVICE_TOKEN, + 'X-localization:'. $this->session->userdata('site_lang') == 'french' ? 'fr' : 'en' + )); + /* set return type json */ + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $body = new \stdClass(); + foreach ($request_body as $key => $value){ + $body->{$key} = $value; + } + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); + + /* execute request */ + $result = curl_exec($ch); + /* close cURL resource */ + curl_close($ch); + + if ($result) { + return $result; + } + } + return json_encode(['status' => 500]); + } + private function isLogged() { if (!$this->session->userdata('email')) { diff --git a/application/controllers/ValidatingDoctor.php b/application/controllers/ValidatingDoctor.php index d7e5d0d4..5c4ff467 100755 --- a/application/controllers/ValidatingDoctor.php +++ b/application/controllers/ValidatingDoctor.php @@ -6,20 +6,50 @@ class ValidatingDoctor extends CI_Controller public function __construct() { parent::__construct(); - $this->load->model('nano_credit_model'); + $this->load->model('nano_health_model'); } - public function index(){ -// if ($this->isLogged()){ + public function index() + { + if ($this->isLogged()){ $data['active'] = "dashboard"; - $this->load->view('nano_health/validating_doctor/header', $data); - $this->load->view('nano_health/validating_doctor/dashboard', $data); - $this->load->view('footer'); -// } + $data['network_id'] = $data['id_network'] = $this->session->userdata('network_id'); + + if ($this->input->get('history')) { + $this->historique($this->input->get('d'), $this->input->get('f'), $this->input->get('history'), $data); + }else{ + + $data['count_d_traite'] = $this->nano_health_model->getCountCareRequests(null,$this->session->userdata('agent_id'), 'ACCEPTED'); + $data['count_d_no_traite'] = $this->nano_health_model->getCountCareRequests($data['network_id'], null, 'UNDER_VALIDATION'); + $data['count_d_no_canceled'] = $this->nano_health_model->getCountCareRequests(null,$this->session->userdata('agent_id'), 'REJECTED'); + + $this->load->view('nano_health/validating_doctor/header', $data); + $this->load->view('nano_health/validating_doctor/dashboard', $data); + $this->load->view('footer'); + } + } } - private function isLogged(){ + private function historique($startDate, $endDate,$type , $data) + { + + $format = $this->session->userdata('site_lang') === 'french' ? 'd-m-Y' : 'Y-m-d'; + $data['startDate'] = $startDate ? date($format, strtotime($startDate)) : null; + $data['endDate'] = $endDate ? date($format, strtotime($endDate)) : null; + $endDate = Date('Y-m-d', strtotime($endDate . "+1 day")); + + if ($type == 'care-requests') + $data['active'] = 'care_requests'; + + $this->load->view('nano_health/validating_doctor/header', $data); + if ($type == 'care-requests') + $this->load->view('nano_health/validating_doctor/care_requests'); + $this->load->view('footer'); + } + + private function isLogged() + { if (!$this->session->userdata('email')) { $this->session->set_flashdata('error', 'log in first'); diff --git a/application/controllers/pagination/CareRequests.php b/application/controllers/pagination/CareRequests.php new file mode 100755 index 00000000..e245de96 --- /dev/null +++ b/application/controllers/pagination/CareRequests.php @@ -0,0 +1,55 @@ +load->model('pagination/CareRequests_model', 'model'); + + + } + + + function getLists() + { + $data = $row = array(); + + // Fetch member's records + $witData = $this->model->getRows($_POST); + + $i = $_POST['start']; + $current_url = $_POST['currentURL']; + foreach ($witData as $row) { + $buttons = "". + ""; + + $data[] = array($row->request_id , $row->user_lastname.' '.$row->user_firstname , $row->user_phone, $row->act_code , $row->act_name, + mb_strtoupper($this->lang->line($row->state),'UTF-8'), $row->created_at , $row->state === 'UNDER_VALIDATION' ? $buttons : null); + + } + + $output = array( + "draw" => $_POST['draw'], + "recordsTotal" => $this->model->countAll($_POST), + "recordsFiltered" => $this->model->countFiltered($_POST), + "data" => $data, + ); + + // Output to JSON format + echo json_encode($output); + } + +} diff --git a/application/language/english/message_lang.php b/application/language/english/message_lang.php index 0cdb76fd..7fa412f2 100755 --- a/application/language/english/message_lang.php +++ b/application/language/english/message_lang.php @@ -856,4 +856,8 @@ $lang['invoice_id'] = "Invoice ID"; $lang['generate_qr_code'] = "Generate QR code"; $lang['display_qr_code'] = "Display QR code"; $lang['insured_phone'] = "Insured phone"; +$lang['care_requests_history'] = "Care request history"; +$lang['no_demand'] = "No requests"; +$lang['request_id'] = "Request ID"; +$lang['export_request_list'] = "Export request list"; ?> diff --git a/application/language/french/message_lang.php b/application/language/french/message_lang.php index 676c1afa..79836438 100755 --- a/application/language/french/message_lang.php +++ b/application/language/french/message_lang.php @@ -867,4 +867,8 @@ $lang['invoice_id'] = "ID de la facture"; $lang['generate_qr_code'] = "Génerer le QR code"; $lang['display_qr_code'] = "Afficher le QR code"; $lang['insured_phone'] = "Téléphone de l'assuré"; +$lang['care_requests_history'] = "Historique des demandes de soins"; +$lang['no_demand'] = "Aucune demande"; +$lang['request_id'] = "ID de la demande"; +$lang['export_request_list'] = "Exporter la liste des demandes"; ?> diff --git a/application/models/Nano_health_model.php b/application/models/Nano_health_model.php index 71a39f0b..7658158b 100644 --- a/application/models/Nano_health_model.php +++ b/application/models/Nano_health_model.php @@ -136,4 +136,16 @@ class Nano_health_model extends CI_Model return [$insuredAmount, $insurerAmount]; } + + public function getCountCareRequests($network_id , $validating_agent_id, $state){ + $query = $this->db->from('nh_infos_authorization_of_care_requests')->where('state',$state); + if(!empty($validating_agent_id)){ + $query = $query->where('validating_agent_id', $validating_agent_id); + } + + if(!empty($network_id)){ + $query = $query->where('network_id', $network_id); + } + return $query->count_all_results(); + } } diff --git a/application/models/pagination/CareRequests_model.php b/application/models/pagination/CareRequests_model.php new file mode 100644 index 00000000..a9a19952 --- /dev/null +++ b/application/models/pagination/CareRequests_model.php @@ -0,0 +1,109 @@ +table = 'nh_infos_authorization_of_care_requests'; + // Set orderable column fields + $this->column_order = array('request_id','user_lastname','act_code', 'act_name', 'state', 'created_at', null); + // Set searchable column fields + $this->column_search = array('request_id','user_lastname','act_code', 'act_name', 'state', 'created_at'); + // Set default order + $this->order = array('created_at' => 'desc'); + } + + /* + * Fetch members data from the database + * @param $_POST filter data based on the posted parameters + */ + public function getRows($postData) + { + $this->_get_datatables_query($postData); + if ($postData['length'] != -1) { + $this->db->limit($postData['length'], $postData['start']); + } + $query = $this->db->get(); + return $query->result(); + } + + /* + * Count all records + */ + public function countAll($postData) + { + $this->db->from($this->table); + if(!empty($postData['id_network'])){ + $this->db->where('network_id', $postData['id_network']); + } + + if(!empty($postData['network_agent_id'])){ + $this->db->where('network_agent_id', $postData['network_agent_id']); + } + return $this->db->count_all_results(); + } + + /* + * Count records based on the filter params + * @param $_POST filter data based on the posted parameters + */ + public function countFiltered($postData) + { + $this->_get_datatables_query($postData); + $query = $this->db->get(); + return $query->num_rows(); + } + + /* + * Perform the SQL queries needed for an server-side processing requested + * @param $_POST filter data based on the posted parameters + */ + private function _get_datatables_query($postData) + { + + $this->db->from($this->table); + if(!empty($postData['id_network'])){ + $this->db->where('network_id', $postData['id_network']); + } + + if(!empty($postData['network_agent_id'])){ + $this->db->where('network_agent_id', $postData['network_agent_id']); + } + if (strlen($postData['startDate']) > 0 && strlen($postData['endDate']) > 0) { + $this->db->where('created_at >=', date('Y-m-d', strtotime($postData['startDate']))); + $this->db->where('created_at <', date('Y-m-d', strtotime($postData['endDate']. "+1 day"))); + } + + $i = 0; + // loop searchable columns + foreach ($this->column_search as $item) { + // if datatable send POST for search + if ($postData['search']['value']) { + // first loop + if ($i === 0) { + // open bracket + $this->db->group_start(); + $this->db->like($item, $postData['search']['value']); + } else { + $this->db->or_like($item, $postData['search']['value']); + } + + // last loop + if (count($this->column_search) - 1 == $i) { + // close bracket + $this->db->group_end(); + } + } + $i++; + } + + if (isset($postData['order'])) { + $this->db->order_by($this->column_order[$postData['order']['0']['column']], $postData['order']['0']['dir']); + } else if (isset($this->order)) { + $order = $this->order; + $this->db->order_by(key($order), $order[key($order)]); + } + } +} diff --git a/application/views/header_agent.php b/application/views/header_agent.php index dc7d40c9..e515bf6c 100755 --- a/application/views/header_agent.php +++ b/application/views/header_agent.php @@ -110,13 +110,13 @@ } ?>"> - lang->line('health_care_sheets'); ?> + lang->line('health_care_sheets'); ?>
  • "> - + - lang->line('invoices'); ?> + lang->line('invoices'); ?>
  • 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 4cbdd16a..2cba9b24 100755 --- a/application/views/nano_health/hyper/infos_health_care_sheet.php +++ b/application/views/nano_health/hyper/infos_health_care_sheet.php @@ -229,7 +229,7 @@

    lang->line('percentage_insured') ?>

    - +
    @@ -241,7 +241,7 @@

    lang->line('percentage_insurer') ?>

    - +
    diff --git a/application/views/nano_health/validating_doctor/care_requests.php b/application/views/nano_health/validating_doctor/care_requests.php new file mode 100755 index 00000000..5ae2a1ae --- /dev/null +++ b/application/views/nano_health/validating_doctor/care_requests.php @@ -0,0 +1,242 @@ + + + + + +
    + + +
    +

    + lang->line('care_requests_history') ?> + + +

    +
    +
    +
    +
    +
    + +
    + lang->line('Période') ?> + + + + + Format : session->userdata('site_lang') === 'french' ? 'Jour - Mois - Année ' : 'Year - Month - Day' ?> +
    +
    +
    + + +
    +
    +
    +
    +
    +

    lang->line('export_request_list') ?>

    +
    +
    +
    +
    + + + + + + + + + + + + + + +
    lang->line('request_id')?>lang->line('one_insured')?>lang->line('Contact')?>lang->line('act_code') ?>lang->line('act') ?>lang->line('state') ?>Date Action
    +
    +
    +
    +
    +
    + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/application/views/nano_health/validating_doctor/dashboard.php b/application/views/nano_health/validating_doctor/dashboard.php index 6f070c62..c73e0a10 100755 --- a/application/views/nano_health/validating_doctor/dashboard.php +++ b/application/views/nano_health/validating_doctor/dashboard.php @@ -1,9 +1,9 @@ - + - + - + db->query("SELECT demande_id FROM info_demandeCredits -// WHERE MONTH(dateAjout) = '".$months[$i-1]."' AND YEAR(dateAjout) = ".$years[$i-1]." -// AND codeParrain='".$this->session->userdata('member_code')."'" -// ); -// $demandes_data[] = $demandes_query_mounth->num_rows(); -// } -// -// $demandes_query = $listdem; -// -// if($demandes_query!=false){ -// $demandes=$demandes_query->num_rows(); -// // Count networks for simple users -// $array_simple = array(); -// $num = 0; -// if ($demandes > 0) { -// foreach($demandes_query->result() as $row) { -// $num++; -// $array_simple[] = $row->codeMembre; -// } -// -// $vals_simple = array_count_values($array_simple); -// //echo 'No. of NON Duplicate Items: '.count($vals_simple).'

    '; -// //print_r($vals_simple); -// $pieChart2 = array(); -// foreach(array_keys($vals_simple) as $paramName2) { -// $color2 = dechex(rand(0x000000, 0xFFFFFF)); -// $trash2 = array("value" => $vals_simple[$paramName2], -// "color" => "#".$color2, -// "highlight" => "#".$color2, -// "label" => $paramName2); -// -// $pieChart2[]= $trash2; -// -// } -// } -// }else{ - $pieChart2 = array(); -// } + $date = date("Y"); - /** - ** Geolocated User Treatment - **/ -// $users_geolocated_query = $list_geolocated_users; -// // Geolocated Users by month replace 2016 by NOW() -// $users_geolocated_data[] = ''; -// $users_geolocated_data =array(); -// for ($i = 1; $i <= 12; $i++) { -// $users_geolocated_query_january = $this->db->query("SELECT agent_id FROM super_infos -// WHERE MONTH(date_created) = '".$months[$i-1]."' AND YEAR(date_created) = ".$years[$i-1]." -// AND category='geolocated' AND code_parrain='".$this->session->userdata('member_code')."'"); -// $users_geolocated_data[] = $users_geolocated_query_january->num_rows(); -// } -// -// if($users_geolocated_query!=false){ -// -// $users_geolocated=$users_geolocated_query->num_rows(); -// //$users_geolocated_query = json_encode($users_geolocated_query->result()); -// // Counts network for geolocated users -// $array_geolocated = array(); -// $num = 0; -// if ($users_geolocated > 0) { -// foreach($users_geolocated_query->result() as $row) { -// $num++; -// $array_geolocated[] = date("M", strtotime($row->date_created)); -// } -// $vals_geolocated = array_count_values($array_geolocated); -// //echo 'No. of NON Duplicate Items: '.count($vals_geolocated).'

    '; -// //print_r($vals_geolocated); -// $pieChart = array(); -// foreach(array_keys($vals_geolocated) as $paramName) { -// $color = dechex(rand(0x000000, 0xFFFFFF)); -// $trash = array("value" => $vals_geolocated[$paramName], -// "color" => "#".$color, -// "highlight" => "#".$color, -// "label" => $paramName); -// -// $pieChart[]= $trash; -// } -// } -// }else{ -// $pieChart = array(); -// } + $demandes_data[] = ''; + $demandes_data =array(); + for ($i = 1; $i <= 12; $i++) { + $demandes_query_mounth = $this->db->query("SELECT id FROM nh_infos_authorization_of_care_requests + WHERE MONTH(created_at) = '".$months[$i-1]."' AND YEAR(created_at) = ".$years[$i-1]." + AND network_id='".$network_id."'" + ); + $demandes_data[] = $demandes_query_mounth->num_rows(); + } + + $pieChart = array(); ?>
    @@ -114,8 +40,8 @@

    - lang->line('validating_doctor'); ?> - lang->line('Tableau de bord'); ?> + lang->line('validating_doctor'); ?> + lang->line('Tableau de bord'); ?>

    @@ -126,42 +52,39 @@
    -

    +

    -

    lang->line('accepted_care_requests'); ?>

    +

    lang->line('accepted_care_requests'); ?>

    - lang->line("Plus d'informations"); ?>
    -

    +

    -

    lang->line('not_treated_care_requests'); ?>

    +

    lang->line('not_treated_care_requests'); ?>

    - lang->line("Plus d'informations"); ?>
    -

    +

    -

    lang->line("cancelled_care_requests"); ?>

    +

    lang->line("cancelled_care_requests"); ?>

    - lang->line("Plus d'informations"); ?>
    @@ -169,7 +92,7 @@
    -

    lang->line('care_requests'); ?>

    +

    lang->line('care_requests'); ?>

    @@ -181,20 +104,6 @@
    -
    - -
    -
    -

    lang->line('care_requests'); ?>

    -
    -
    - -
    - -
    - -
    -
    @@ -203,67 +112,67 @@ - + - + - + - + - + - - + + - + - - + + - + - + - + - + - + - + - + - + diff --git a/application/views/nano_health/validating_doctor/header.php b/application/views/nano_health/validating_doctor/header.php index 08ce63c8..362e7ec0 100755 --- a/application/views/nano_health/validating_doctor/header.php +++ b/application/views/nano_health/validating_doctor/header.php @@ -117,8 +117,8 @@ -
  • "> - +
  • "> + lang->line('care_requests'); ?>