Add Health Care Sheet form in agent panel

This commit is contained in:
Djery-Tom 2021-12-28 16:51:25 +01:00
parent a136faf988
commit 831d70a1c2
7 changed files with 605 additions and 237 deletions

View File

@ -28,7 +28,8 @@ class Agent extends CI_Controller
$data['network'] = $this->session->userdata('network');
$data['code_parrain'] = $this->session->userdata('parrain');
$data['network_agent_id'] = $this->session->userdata('network_agent_id');
$data['hasWallet'] = $this->wallet_model->getConfigWallet($this->session->userdata('network_id'));
$data['network_id'] = $data['id_network'] = $this->session->userdata('network_id');
$data['hasWallet'] = $this->wallet_model->getConfigWallet($data['network_id']);
if ($this->input->get('history')) {
if($this->input->get('id') !== null){
@ -51,6 +52,13 @@ class Agent extends CI_Controller
}
}else if($this->input->get('action')) {
$nh_config = $this->nano_health_model->getConfig($data['network_id']);
$data['nh_config'] = $nh_config ? $nh_config->first_row() : null ;
$data['config_id'] = $data['nh_config'] ? $data['nh_config']->id : null ;
$data['acts'] = $this->nano_health_model->getConfigActs($data['config_id']);
$data['provider_classes'] = $this->nano_health_model->getProviderClasses($data['config_id']);
$data['drugs_and_devices'] = $this->nano_health_model->getDrugAndDevices($data['network_id']);
$this->load->view('header_agent', $data);
$this->load->view('nano_health/agent/health_care_sheet_form');
$this->load->view('footer');

View File

@ -304,6 +304,81 @@ class NanoHealthController extends CI_Controller
}
}
public function getInsured()
{
if($this->isLogged()) {
if (isset($_POST)) {
$url = NANO_SANTE_SERVICE_URL.'/insured';
$dataArray = [
'network_id' => $this->input->post('network_id'),
];
$query = $this->input->post('query');
$option = $this->input->post('option');
$dataArray[$option ?? 'name'] = $query;
$data = http_build_query($dataArray);
// $getUrl = $url."?".$data;
$ch = curl_init($url."?".$data);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
/* 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);
/* execute request */
$result = curl_exec($ch);
/* close cURL resource */
curl_close($ch);
if ($result) {
echo $result;
} else {
echo json_encode(['status' => 500]);
}
}
}
}
public function saveHealthCareSheetConsultation()
{
if($this->isLogged()) {
if (isset($_POST)) {
$url = NANO_SANTE_SERVICE_URL.'/health-care-sheets/consultation';
$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]);
}
}
}
}
private function isLogged()
{

View File

@ -822,4 +822,11 @@ $lang['insurance_part'] = "Insurance share";
$lang['insurance_part'] = "Insurance share";
$lang['consultation_id'] = "Consulation ID";
$lang['new_care_sheet'] = "Enter a care sheet";
$lang['new_prestation'] = "New service";
$lang['new_exam'] = "New exam";
$lang['new_prescription'] = "New prescription";
$lang['user_phone_number'] = "User phone number";
$lang['insured_not_found'] = "This insured does not exist";
$lang['finding_insured_by'] = "Finding the insured by:";
$lang['one_insured'] = "Insured";
?>

View File

@ -833,4 +833,11 @@ $lang['insurance_part'] = "Part de l'assurance";
$lang['insurance_part'] = "Part de l'assurance";
$lang['consultation_id'] = "ID de la consultation";
$lang['new_care_sheet'] = "Saisir une feuille de soins";
$lang['new_prestation'] = "Nouvelle prestation";
$lang['new_exam'] = "Nouvel examen";
$lang['new_prescription'] = "Nouvelle prescription";
$lang['user_phone_number'] = "Numéro de téléphone de l'usager";
$lang['insured_not_found'] = "Cet assuré n'existe pas";
$lang['finding_insured_by'] = "Recherche de l'assuré par :";
$lang['one_insured'] = "Assuré"
?>

View File

@ -101,4 +101,9 @@ class Nano_health_model extends CI_Model
->join('nh_drugs_and_devices d', 'd.id = p.drug_or_device_id')
->where('sp.sheet_id',$healthCareSheetId)->order_by('sp.created_at','asc')->get();
}
public function getDrugAndDevices($networkId)
{
return $this->db->get_where('nh_drugs_and_devices',['network_id'=> $networkId]);
}
}

View File

@ -39,12 +39,39 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
</div>
<!-- /.box-header -->
<!-- form start -->
<form role="form" id="walletForm">
<form id="sheet-form">
<div class="box-body">
<div class="row" style="margin-bottom: 30px">
<div class="col-md-6">
<div class="form-group">
<label><?= $this->lang->line('one_insured')?></label>
<select class="form-control" name="insured_id" required>
<option value="" selected disabled> Choisissez l'assuré</option>
</select>
</div>
<div class="form-group" id="patient">
<label>Patient</label>
<select class="form-control" name="beneficiary_id" required>
<option value="" selected disabled> Choisissez le patient</option>
</select>
</div>
<div id="patient-details">
<div class="form-group">
<label><?= $this->lang->line('patient_lastname')?></label>
<input class="form-control" name="patient_lastname" required>
</div>
<div class="form-group">
<label><?= $this->lang->line('patient_firstname')?></label>
<input class="form-control" name="patient_firstname">
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label><?= $this->lang->line('practitioner_lastname')?></label>
<input class="form-control" name="practitioner_lastname">
<input class="form-control" name="practitioner_lastname" required>
</div>
<div class="form-group">
<label><?= $this->lang->line('practitioner_firstname')?></label>
@ -52,19 +79,25 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
</div>
<div class="form-group">
<label>Classification</label>
<input class="form-control" name="practitioner_firstname">
<select required class="form-control" name="practitioner_provider_class_id">
<?php foreach ($provider_classes->result() as $row) { ?>
<option value="<?=$row->id ?>"> <?= $row->name ?></option>
<?php } ?>
</select>
</div>
<div class="form-group">
<label><?= $this->lang->line('care_condition')?></label>
<label>
<select class="form-control" name="care_condition">
<select class="form-control" name="care_condition" required>
<option value="CURRENT_AFFECTION"> <?= $this->lang->line('CURRENT_AFFECTION')?></option>
<option value="LONG_TERM_AFFECTION"> <?= $this->lang->line('LONG_TERM_AFFECTION')?></option>
<option value="EXONERATION"> <?= $this->lang->line('EXONERATION')?></option>
</select>
</label>
</div>
<div class="form-group" style="overflow-x:auto;">
</div>
</div>
<div class="form-group mt-2" style="overflow-x:auto;">
<div class="table-title">
<div class="row">
<div class="col-sm-8">
@ -73,24 +106,26 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
</div>
<div class="col-sm-4">
<button type="button" class="btn btn-info add-new new1"><i
class="fa fa-plus"></i> <?php echo $this->lang->line('new_level'); ?>
class="fa fa-plus"></i> <?php echo $this->lang->line('new_prestation'); ?>
</button>
</div>
</div>
</div>
<table id="user_wallet_wallet" class="table table-bordered">
<table id="prestations" class="table table-bordered">
<thead>
<tr>
<th>Min</th>
<th>Max</th>
<th><?php echo $this->lang->line('rate'); ?> (%)</th>
<th><?php echo $this->lang->line('act_code'); ?> </th>
<th><?php echo $this->lang->line('Montant'); ?></th>
<th><?= $this->lang->line('moderator_ticket'); ?></th>
<th><?= $this->lang->line('insurance_amount'); ?></th>
<th><?= $this->lang->line('home_visit_fees'); ?></th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
if (isset($plr_user_wallet_wallet)) {
foreach ($plr_user_wallet_wallet->result() as $row) {
if (isset($plr_prestations)) {
foreach ($plr_prestations->result() as $row) {
echo "<tr>
<td>" . $row->min . "</td>
<td>" . $row->max . "</td>
@ -107,50 +142,7 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
</tbody>
</table>
</div>
<div class="form-group" style="overflow-x:auto;">
<div class="table-title">
<div class="row">
<div class="col-sm-8">
<label for="nom"
class="col-form-label"><?php echo $this->lang->line('medical_prescriptions'); ?></label>
</div>
<div class="col-sm-4">
<button type="button" class="btn btn-info add-new new7"><i
class="fa fa-plus"></i> <?php echo $this->lang->line('new_level'); ?>
</button>
</div>
</div>
</div>
<table id="user_wallet_wallet_national" class="table table-bordered">
<thead>
<tr>
<th>Min</th>
<th>Max</th>
<th><?php echo $this->lang->line('rate'); ?> (%)</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
if (isset($plr_user_wallet_wallet_national)) {
foreach ($plr_user_wallet_wallet_national->result() as $row) {
echo "<tr>
<td>" . $row->min . "</td>
<td>" . $row->max . "</td>
<td>" . $row->taux . "</td>" . '
<td>
<a class="add add7" title="Add" data-toggle="tooltip"><i class="material-icons">&#xE03B;</i></a>
<a class="edit edit7" title="Edit" data-toggle="tooltip"><i class="material-icons">&#xE254;</i></a>
<a class="delete delete7" title="Delete" data-toggle="tooltip"><i class="material-icons">&#xE872;</i></a>
</td>
</tr>';
}
}
?>
</tbody>
</table>
</div>
<div class="form-group" style="overflow-x:auto;">
<div class="form-group mt-4" style="overflow-x:auto;">
<div class="table-title">
<div class="row">
<div class="col-sm-8">
@ -158,33 +150,33 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
class="col-form-label"><?php echo $this->lang->line('exams'); ?></label>
</div>
<div class="col-sm-4">
<button type="button" class="btn btn-info add-new new7"><i
class="fa fa-plus"></i> <?php echo $this->lang->line('new_level'); ?>
<button type="button" class="btn btn-info add-new new2"><i
class="fa fa-plus"></i> <?php echo $this->lang->line('new_exam'); ?>
</button>
</div>
</div>
</div>
<table id="user_wallet_wallet_national" class="table table-bordered">
<table id="exams" class="table table-bordered">
<thead>
<tr>
<th>Min</th>
<th>Max</th>
<th><?php echo $this->lang->line('rate'); ?> (%)</th>
<th><?= $this->lang->line('exam_class'); ?></th>
<th><?= $this->lang->line('exam_description'); ?></th>
<th><?= $this->lang->line('quantity'); ?></th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
if (isset($plr_user_wallet_wallet_national)) {
foreach ($plr_user_wallet_wallet_national->result() as $row) {
if (isset($plr_prescriptions)) {
foreach ($plr_prescriptions->result() as $row) {
echo "<tr>
<td>" . $row->min . "</td>
<td>" . $row->max . "</td>
<td>" . $row->taux . "</td>" . '
<td>
<a class="add add7" title="Add" data-toggle="tooltip"><i class="material-icons">&#xE03B;</i></a>
<a class="edit edit7" title="Edit" data-toggle="tooltip"><i class="material-icons">&#xE254;</i></a>
<a class="delete delete7" title="Delete" data-toggle="tooltip"><i class="material-icons">&#xE872;</i></a>
<a class="add add2" title="Add" data-toggle="tooltip"><i class="material-icons">&#xE03B;</i></a>
<a class="edit edit2" title="Edit" data-toggle="tooltip"><i class="material-icons">&#xE254;</i></a>
<a class="delete delete2" title="Delete" data-toggle="tooltip"><i class="material-icons">&#xE872;</i></a>
</td>
</tr>';
}
@ -193,6 +185,55 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
</tbody>
</table>
</div>
<div class="form-group mt-4" style="overflow-x:auto;">
<div class="table-title">
<div class="row">
<div class="col-sm-8">
<label for="nom"
class="col-form-label"><?php echo $this->lang->line('medical_prescriptions'); ?></label>
</div>
<div class="col-sm-4">
<button type="button" class="btn btn-info add-new new3"><i
class="fa fa-plus"></i> <?php echo $this->lang->line('new_prescription'); ?>
</button>
</div>
</div>
</div>
<table id="prescriptions" class="table table-bordered">
<thead>
<tr>
<th><?= $this->lang->line('drugs_or_device'); ?></th>
<th><?= $this->lang->line('dosage'); ?></th>
<th><?= $this->lang->line('quantity'); ?></th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
if (isset($plr_prescriptions)) {
foreach ($plr_prescriptions->result() as $row) {
echo "<tr>
<td>" . $row->min . "</td>
<td>" . $row->max . "</td>
<td>" . $row->taux . "</td>" . '
<td>
<a class="add add3" title="Add" data-toggle="tooltip"><i class="material-icons">&#xE03B;</i></a>
<a class="edit edit3" title="Edit" data-toggle="tooltip"><i class="material-icons">&#xE254;</i></a>
<a class="delete delete3" title="Delete" data-toggle="tooltip"><i class="material-icons">&#xE872;</i></a>
</td>
</tr>';
}
}
?>
</tbody>
</table>
</div>
<div class="form-group">
<label><?= $this->lang->line('mot de passe')?></label>
<input type="password" class="form-control" name="password" required>
</div>
</div>
<!-- /.box-body -->
@ -240,80 +281,170 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
toastr.options.closeDuration = 5000;
toastr.options.closeEasing = 'swing';
$('#updateWallet').click(function () {
const network_id = $(this).data('network-id');
const id_config = $(this).data('id-config');
if ($('#walletForm')[0].checkValidity()) {
$(document).ready(function (){
$('#patient').hide();
$('#patient-details').hide();
// Get The Data
const insured = JSON.parse(sessionStorage.getItem('insured'));
if(insured && Array.isArray(insured)){
var currentInsurance = null
// console.log('insured', insured)
// insured.each()
$.each(insured, function (i, item) {
$('#sheet-form').find('select[name="insured_id"]').append($('<option>', {
value: item.insured_id,
text : item.insured_id+' - '+item.user.lastname +' '+(item.user.firstname || '')
}));
});
$('#sheet-form').find('select[name="insured_id"]').change(function () {
const insurance = insured.filter(i => i.insured_id === $(this).val());
$.each(insurance, function (i, item) {
currentInsurance = item;
$('#sheet-form').find('select[name="beneficiary_id"]').append($('<optgroup>', {
label: 'Assuré principal',
}));
$('#sheet-form').find('select[name="beneficiary_id"]').append($('<option>', {
value: 0,
text : item.user.lastname +' '+(item.user.firstname || '')
}));
$('#sheet-form').find('select[name="beneficiary_id"]').append($('<optgroup>', {
label: 'Ayants droits',
}));
$.each(item.beneficiaries, function (j, it) {
$('#sheet-form').find('select[name="beneficiary_id"]').append($('<option>', {
value: it.id,
text : it.lastname +' '+it.firstname
}));
});
});
$('#patient').show();
});
$('#sheet-form').find('select[name="beneficiary_id"]').change(function () {
var val = parseInt($(this).val());
if(val === 0){
$('#sheet-form').find('input[name="patient_lastname"]').val(currentInsurance.user.lastname)
$('#sheet-form').find('input[name="patient_firstname"]').val(currentInsurance.user.firstname)
}else{
const b = currentInsurance.beneficiaries.filter(i => i.id === val);
$('#sheet-form').find('input[name="patient_lastname"]').val(b[0].lastname)
$('#sheet-form').find('input[name="patient_firstname"]').val(b[0].firstname)
}
$('#patient-details').show();
});
}else{
history.back()
}
})
$("#sheet-form").submit(function(e){
e.preventDefault();
// Paliers
var plr_user_wallet_wallet = [];
var prestations = [];
var exams = [];
var prescriptions = [];
var plr_user_wallet_wallet_national = [];
$('#user_wallet_wallet tr').has('td').each(function () {
$('#prestations tr').has('td').each(function () {
var arrayItem = {};
$('td', $(this)).each(function (index, item) {
if (index < 3)
arrayItem[index] = parseFloat($(item).html());
if (index === 0)
arrayItem['act_id'] = $(item).attr('value');
if (index === 1)
arrayItem['amount'] = parseFloat($(item).html());
if (index === 4)
arrayItem['home_visit_fees'] = parseFloat($(item).html()) || null;
});
plr_user_wallet_wallet.push(arrayItem);
prestations.push(arrayItem);
});
$('#user_wallet_wallet_national tr').has('td').each(function () {
$('#exams tr').has('td').each(function () {
var arrayItem = {};
$('td', $(this)).each(function (index, item) {
if (index < 3)
arrayItem[index] = parseFloat($(item).html());
if (index === 0)
arrayItem['act_id'] = $(item).attr('value');
if (index === 1)
arrayItem['description'] = $(item).html();
if (index === 2)
arrayItem['quantity'] = parseFloat($(item).html());
});
plr_user_wallet_wallet_national.push(arrayItem);
exams.push(arrayItem);
});
$('#prescriptions tr').has('td').each(function () {
var arrayItem = {};
$('td', $(this)).each(function (index, item) {
if (index === 0)
arrayItem['drug_or_device_id'] = $(item).attr('value');
if (index === 1)
arrayItem['dosage'] = $(item).html();
if (index === 2)
arrayItem['quantity'] = parseFloat($(item).html());
});
prescriptions.push(arrayItem);
});
if(prestations.length === 0){
return toastr.error("Vous devez saisir au moins une prestation", "<?php echo $this->lang->line('request_error')?>");
}
var unindexed_array = $(this).serializeArray();
var indexed_array = {};
$.map(unindexed_array, function(n, i){
indexed_array[n['name']] = n['value'];
});
indexed_array.beneficiary_id = parseInt(indexed_array.beneficiary_id) === 0 ? null : indexed_array.beneficiary_id;
$.ajax({
url: '<?php echo base_url('Gestion/config_wallet/update')?>',
url: '<?php echo base_url('NanoHealthController/saveHealthCareSheetConsultation')?>',
type: 'POST',
dataType: 'json',
data: {
"type": "ilink",
"config":"user_wallet_wallet",
"network_id": network_id, "id_config": id_config,
"plr_user_wallet_wallet": plr_user_wallet_wallet,
"plr_user_wallet_wallet_national": plr_user_wallet_wallet_national,
...indexed_array, "network_agent_id" : "<?= $network_agent_id ?>",
"performances": prestations, "exams": exams, "prescriptions": prescriptions,
},
success: function (data) {
if (data == '200') {
if(data.status === 200){
Swal.fire({
icon: 'success',
title: "<?php echo $this->lang->line('wallet_update')?>",
text: "<?php echo $this->lang->line('informations_updated')?>",
title: "<?= $this->lang->line('drug_and_device_updated')?>",
text:"<?= $this->lang->line('informations_updated')?>",
timer: 3000
}).then(() => {
}).then(()=>{
location.reload();
});
// alert("Les informations ont été mises à jour.") ? "" :
} else {
toastr.error("<?php echo $this->lang->line('error_message')?>", "<?php echo $this->lang->line('request_error')?>");
}else{
toastr.error(data.error , "<?= $this->lang->line('request_error')?>");
}
},
error: function (resultat, statut, error) {
console.log(resultat + " " + error);
toastr.error("<?php echo $this->lang->line('error_message')?>", "<?php echo $this->lang->line('request_error')?>");
}
});
} else {
$('#walletForm')[0].reportValidity();
}
});
</script>
<script type="text/javascript">
// Paliers scripts
$(document).ready(function () {
function getActsOptions(selectedValue) {
var actsOptions = '';
<?php foreach ($acts->result() as $a ) {?>
var id = <?= $a->id ?>;
var selected = id === parseInt(selectedValue) ? 'selected' : '';
actsOptions += (`<option value=<?= $a->id ?> ${selected} > <?= $a->name ?> </option>`);
<?php } ?>
return actsOptions;
}
$('[data-toggle="tooltip"]').tooltip();
var actions1 = $("#user_wallet_wallet td:last-child").html();
var actions1 = $("#prestations td:last-child").html();
// Append table with add row form on add new button click
$(".new1").click(function () {
if (!actions1) {
@ -322,42 +453,30 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
' <a class="delete delete1" title="Delete" data-toggle="tooltip"><i class="material-icons">&#xE872;</i></a>';
}
$(this).attr("disabled", "disabled");
var index = $("#user_wallet_wallet tbody tr:last-child").index();
var index = $("#prestations tbody tr:last-child").index();
var row = '<tr>' +
'<td><input type="number" required min="0" class="form-control" name="min" id="min"></td>' +
'<td><input type="number" required class="form-control" name="max" id="max"></td>' +
'<td><input type="number" required class="form-control" min="0" name="taux" id="taux"></td>' +
'<td>' +
'<select required class="form-control" name="act_id" >' +
getActsOptions(null)+
'</select>' +
'</td>' +
'<td><input type="number" required class="form-control" name="amount" min="0"></td>' +
'<td><input class="form-control" name="moderator_ticket" disabled></td>' +
'<td><input class="form-control" name="insurance_amount" disabled ></td>' +
'<td><input type="number" class="form-control" name="home_visit_fees" min="0"></td>' +
'<td> ' + actions1 + '</td>' +
'</tr>';
$("#user_wallet_wallet").append(row);
$("#user_wallet_wallet tbody tr").eq(index + 1).find(".add, .edit").toggle();
$("#prestations").append(row);
$("#prestations tbody tr").eq(index + 1).find(".add, .edit").toggle();
$('[data-toggle="tooltip"]').tooltip();
});
// Add row on add button click
$(document).on("click", ".add1", function () {
var empty = false;
var input = $(this).parents("tr").find('input[type="number"]');
var min = parseFloat($(this).parents("tr").find('input[id="min"]').first().val());
var max = parseFloat($(this).parents("tr").find('input[id="max"]').first().val());
var input = $(this).parents("tr").find('input');
var select = $(this).parents("tr").find('select');
input.each(function () {
if ($(this).attr('id') == 'min') {
if (min >= max) {
$(this).addClass("error");
$(this)[0].reportValidity();
empty = true;
} else {
$(this).removeClass("error");
}
} else if ($(this).attr('id') == 'max') {
if (max <= min) {
$(this).addClass("error");
$(this)[0].reportValidity();
empty = true;
} else {
$(this).removeClass("error");
}
} else {
if (!$(this)[0].checkValidity()) {
$(this).addClass("error");
$(this)[0].reportValidity();
@ -365,7 +484,6 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
} else {
$(this).removeClass("error");
}
}
});
$(this).parents("tr").find(".error").first().focus();
if (!empty) {
@ -375,16 +493,24 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
$(this).parents("tr").find(".add, .edit").toggle();
$(".new1").removeAttr("disabled");
}
select.each(function () {
$(this).parent("td").html($(this).find('option:selected').text()).attr("value",$(this).val());
});
});
// Edit row on edit button click
$(document).on("click", ".edit1", function () {
$(this).parents("tr").find("td:not(:last-child)").each(function (index) {
if (index == 0)
$(this).html('<input type="number" required class="form-control" min="0" id="min" value="' + $(this).text() + '">');
$(this).html('<select class="form-control" name="act_id" required >'+ getActsOptions($(this).attr("value"))+ '</select>');
if (index == 1)
$(this).html('<input type="number" required class="form-control" id="max" value="' + $(this).text() + '">');
$(this).html('<input type="number" required class="form-control" name="amount" min="0" value="' + $(this).text() + '">');
if (index == 2)
$(this).html('<input type="number" required class="form-control" min="0" value="' + $(this).text() + '">');
$(this).html('<input class="form-control" name="moderator_ticket" disabled value="' + $(this).text() + '">');
if (index == 3)
$(this).html('<input class="form-control" name="insurance_amount" disabled value="' + $(this).text() + '">');
if (index == 4)
$(this).html('<input type="number" class="form-control" name="home_visit_fees" min="0" value="' + $(this).text() + '">');
});
$(this).parents("tr").find(".add, .edit").toggle();
$(".new1").attr("disabled", "disabled");
@ -395,55 +521,39 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
$(".new1").removeAttr("disabled");
});
// Table Examens
// Paliers nationaux
// Table 7
var actions7 = $("#user_wallet_wallet_national td:last-child").html();
// Append table with add row form on add new button click
$(".new7").click(function () {
if (!actions7) {
actions7 = '<a class="add add7" title="Add" data-toggle="tooltip"><i class="material-icons">&#xE07B;</i></a>\n' +
' <a class="edit edit7" title="Edit" data-toggle="tooltip"><i class="material-icons">&#xE254;</i></a>\n' +
' <a class="delete delete7" title="Delete" data-toggle="tooltip"><i class="material-icons">&#xE872;</i></a>';
var actions2 = $("#exams td:last-child").html();
// Append table with add row form on add new button click
$(".new2").click(function () {
if (!actions2) {
actions2 = '<a class="add add2" title="Add" data-toggle="tooltip"><i class="material-icons">&#xE03B;</i></a>\n' +
' <a class="edit edit2" title="Edit" data-toggle="tooltip"><i class="material-icons">&#xE254;</i></a>\n' +
' <a class="delete delete2" title="Delete" data-toggle="tooltip"><i class="material-icons">&#xE872;</i></a>';
}
$(this).attr("disabled", "disabled");
var index = $("#user_wallet_wallet_national tbody tr:last-child").index();
var index = $("#exams tbody tr:last-child").index();
var row = '<tr>' +
'<td><input type="number" required min="0" class="form-control" name="min" id="min"></td>' +
'<td><input type="number" required class="form-control" name="max" id="max"></td>' +
'<td><input type="number" required class="form-control" name="taux" id="taux"></td>' +
'<td> ' + actions7 + '</td>' +
'<td>' +
'<select required class="form-control" name="act_id" >' +
getActsOptions(null)+
'</select>' +
'</td>' +
'<td><input class="form-control" name="description"></td>' +
'<td><input class="form-control" name="quantity" min="1" step="1" type="number"></td>' +
'<td> ' + actions2 + '</td>' +
'</tr>';
$("#user_wallet_wallet_national").append(row);
$("#user_wallet_wallet_national tbody tr").eq(index + 1).find(".add, .edit").toggle();
$("#exams").append(row);
$("#exams tbody tr").eq(index + 1).find(".add, .edit").toggle();
$('[data-toggle="tooltip"]').tooltip();
});
// Add row on add button click
$(document).on("click", ".add7", function () {
// Add row on add button click
$(document).on("click", ".add2", function () {
var empty = false;
var input = $(this).parents("tr").find('input[type="number"]');
var min = parseFloat($(this).parents("tr").find('input[id="min"]').first().val());
var max = parseFloat($(this).parents("tr").find('input[id="max"]').first().val());
var input = $(this).parents("tr").find('input');
var select = $(this).parents("tr").find('select');
input.each(function () {
if ($(this).attr('id') == 'min') {
if (min >= max) {
$(this).addClass("error");
$(this)[0].reportValidity();
empty = true;
} else {
$(this).removeClass("error");
}
} else if ($(this).attr('id') == 'max') {
if (max <= min) {
$(this).addClass("error");
$(this)[0].reportValidity();
empty = true;
} else {
$(this).removeClass("error");
}
} else {
if (!$(this)[0].checkValidity()) {
$(this).addClass("error");
$(this)[0].reportValidity();
@ -451,7 +561,6 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
} else {
$(this).removeClass("error");
}
}
});
$(this).parents("tr").find(".error").first().focus();
if (!empty) {
@ -459,26 +568,114 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
$(this).parent("td").html($(this).val());
});
$(this).parents("tr").find(".add, .edit").toggle();
$(".new7").removeAttr("disabled");
$(".new2").removeAttr("disabled");
}
select.each(function () {
$(this).parent("td").html($(this).find('option:selected').text()).attr("value",$(this).val());
});
// Edit row on edit button click
$(document).on("click", ".edit7", function () {
});
// Edit row on edit button click
$(document).on("click", ".edit2", function () {
$(this).parents("tr").find("td:not(:last-child)").each(function (index) {
if (index == 0)
$(this).html('<input type="number" required class="form-control" min="0" id="min" value="' + $(this).text() + '">');
$(this).html('<select class="form-control" name="act_id" required >'+ getActsOptions($(this).attr("value"))+ '</select>');
if (index == 1)
$(this).html('<input type="number" required class="form-control" id="max" value="' + $(this).text() + '">');
$(this).html('<input class="form-control" name="description" value="' + $(this).text() + '">');
if (index == 2)
$(this).html('<input type="number" required class="form-control" min="0" value="' + $(this).text() + '">');
$(this).html('<input class="form-control" name="quantity" min="1" step="1" value="' + $(this).text() + '">');
});
$(this).parents("tr").find(".add, .edit").toggle();
$(".new7").attr("disabled", "disabled");
$(".new2").attr("disabled", "disabled");
});
// Delete row on delete button click
$(document).on("click", ".delete2", function () {
$(this).parents("tr").remove();
$(".new2").removeAttr("disabled");
});
// Table prescription
function getDrugAndDevicesOptions(selectedValue) {
var actsOptions = '';
<?php foreach ($drugs_and_devices->result() as $a ) {?>
var id = <?= $a->id ?>;
var selected = id === parseInt(selectedValue) ? 'selected' : '';
actsOptions += (`<option value=<?= $a->id ?> ${selected} > <?= $a->name ?> </option>`);
<?php } ?>
return actsOptions;
}
// Table prescriptions
var actions3 = $("#prescriptions td:last-child").html();
// Append table with add row form on add new button click
$(".new3").click(function () {
if (!actions3) {
actions3 = '<a class="add add3" title="Add" data-toggle="tooltip"><i class="material-icons">&#xE07B;</i></a>\n' +
' <a class="edit edit3" title="Edit" data-toggle="tooltip"><i class="material-icons">&#xE254;</i></a>\n' +
' <a class="delete delete3" title="Delete" data-toggle="tooltip"><i class="material-icons">&#xE872;</i></a>';
}
$(this).attr("disabled", "disabled");
var index = $("#prescriptions tbody tr:last-child").index();
var row = '<tr>' +
'<td>' +
'<select required class="form-control" name="drug_or_device_id" >' +
getDrugAndDevicesOptions(null)+
'</select>' +
'</td>' +
'<td><input required class="form-control" name="dosage" ></td>' +
'<td><input type="number" required class="form-control" min="1" step="1" name="quantity"></td>' +
'<td> ' + actions3 + '</td>' +
'</tr>';
$("#prescriptions").append(row);
$("#prescriptions tbody tr").eq(index + 1).find(".add, .edit").toggle();
$('[data-toggle="tooltip"]').tooltip();
});
// Add row on add button click
$(document).on("click", ".add3", function () {
var empty = false;
var input = $(this).parents("tr").find('input');
var select = $(this).parents("tr").find('select');
input.each(function () {
if (!$(this)[0].checkValidity()) {
$(this).addClass("error");
$(this)[0].reportValidity();
empty = true;
} else {
$(this).removeClass("error");
}
});
$(this).parents("tr").find(".error").first().focus();
if (!empty) {
input.each(function () {
$(this).parent("td").html($(this).val());
});
$(this).parents("tr").find(".add, .edit").toggle();
$(".new3").removeAttr("disabled");
}
select.each(function () {
$(this).parent("td").html($(this).find('option:selected').text()).attr("value",$(this).val());
});
});
// Edit row on edit button click
$(document).on("click", ".edit3", function () {
$(this).parents("tr").find("td:not(:last-child)").each(function (index) {
if (index == 0)
$(this).html('<select class="form-control" name="drug_or_device_id" required >'+ getDrugAndDevicesOptions($(this).attr("value"))+ '</select>');
if (index == 1)
$(this).html('<input required class="form-control" name="dosage" value="' + $(this).text() + '">');
if (index == 2)
$(this).html('<input type="number" required class="form-control" name="quantity" min="1" step="1" value="' + $(this).text() + '">');
});
$(this).parents("tr").find(".add, .edit").toggle();
$(".new3").attr("disabled", "disabled");
});
// Delete row on delete button click
$(document).on("click", ".delete7", function () {
$(document).on("click", ".delete3", function () {
$(this).parents("tr").remove();
$(".new7").removeAttr("disabled");
$(".new3").removeAttr("disabled");
});
});
</script>

View File

@ -44,9 +44,9 @@
<div class="box-header">
<h3 class="box-title"><?= $this->lang->line('export_health_care_sheets_list') ?></h3>
<div class="box-tools">
<a class="btn btn-primary" href="<?= current_url().('?action=new')?>">
<button class="btn btn-success" data-toggle="modal" data-target="#modal-add">
<?= $this->lang->line('new_care_sheet'); ?>
</a>
</button>
</div>
</div>
<div class="box-body" style="overflow-x:auto;">
@ -72,6 +72,40 @@
</div>
</div>
</div>
<div class="modal fade" id="modal-add">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h3 class="modal-title"><?= $this->lang->line('new_care_sheet'); ?></h3>
</div>
<div class="modal-body">
<form id="search-form">
<div class="form-group">
<label class="col-form-label"><?= $this->lang->line('finding_insured_by'); ?></label>
<select class="form-control" name="option">
<option value="name"><?= $this->lang->line('Nom'); ?></option>
<option value="phone"><?= $this->lang->line('Telephone'); ?></option>
</select>
</div>
<div class="form-group">
<input type="text" required class="form-control" name="query">
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left"
data-dismiss="modal"><?= $this->lang->line('Fermer'); ?></button>
<button type="button" id="check-insured"
class="btn btn-primary"><?= $this->lang->line('Continuer'); ?></button>
</div>
</div>
</div>
</div>
</section>
@ -208,3 +242,38 @@
});
</script>
<script>
$('#check-insured').click(function () {
if ($('#search-form')[0].checkValidity()) {
let option = $('#search-form').find('select[name="option"]').val();
let query = $('#search-form').find('input[name="query"]').val();
$.ajax({
url: '<?= base_url('NanoHealthController/getInsured')?>',
type: 'POST',
dataType: 'json',
data: { network_id : "<?= $id_network ?? null ?>" , query : query , option : option},
success: function (data) {
if(data.status === 200){
if (data.response.length === 0 ) {
toastr.error("<?= $this->lang->line('insured_not_found')?>", "<?= $this->lang->line('request_error')?>");
}else{
// Set data
sessionStorage.setItem('insured' , JSON.stringify(data.response));
window.location = '<?= current_url().('?action=new')?>';
}
}else{
toastr.error(data.error , "<?= $this->lang->line('request_error')?>");
}
},
error: function (resultat, statut, error) {
console.log(resultat + " " + error);
toastr.error("<?= $this->lang->line('error_message')?>", "<?= $this->lang->line('request_error')?>");
}
});
} else {
$('#search-form')[0].reportValidity();
}
});
</script>