Add Health Care Sheet Execution

This commit is contained in:
Djery-Tom 2022-01-05 11:49:55 +01:00
parent 831d70a1c2
commit 8aed9f4d09
8 changed files with 716 additions and 20 deletions

View File

@ -30,6 +30,7 @@ class Agent extends CI_Controller
$data['network_agent_id'] = $this->session->userdata('network_agent_id');
$data['network_id'] = $data['id_network'] = $this->session->userdata('network_id');
$data['hasWallet'] = $this->wallet_model->getConfigWallet($data['network_id']);
$data['show_health_care_sheet_buttons'] = true;
if ($this->input->get('history')) {
if($this->input->get('id') !== null){
@ -52,6 +53,7 @@ class Agent extends CI_Controller
}
}else if($this->input->get('action')) {
$action = $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 ;
@ -60,7 +62,11 @@ class Agent extends CI_Controller
$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');
if($action == 'new_consultation'){
$this->load->view('nano_health/agent/health_care_sheet_consultation_form');
} else {
$this->load->view('nano_health/agent/health_care_sheet_execution_form');
}
$this->load->view('footer');
}else{
$startDate = $this->input->get('d');

View File

@ -344,11 +344,11 @@ class NanoHealthController extends CI_Controller
}
}
public function saveHealthCareSheetConsultation()
public function saveHealthCareSheet($type = 'consultation')
{
if($this->isLogged()) {
if (isset($_POST)) {
$url = NANO_SANTE_SERVICE_URL.'/health-care-sheets/consultation';
$url = NANO_SANTE_SERVICE_URL.'/health-care-sheets/'.$type;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
/* set the content type json */
@ -379,6 +379,73 @@ class NanoHealthController extends CI_Controller
}
}
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]);
}
}
}
}
public function getHealthCareSheets()
{
if($this->isLogged()) {
if (isset($_POST)) {
$url = NANO_SANTE_SERVICE_URL.'/health-care-sheets';
$data = http_build_query($_POST);
// $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]);
}
}
}
}
private function isLogged()
{

View File

@ -829,4 +829,10 @@ $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";
$lang['new_consultation'] = "Enter a consultation" ;
$lang['accident'] = "Accident" ;
$lang['pregnancy'] = "Pregnancy care" ;
$lang['consultation_entered'] = "Consultation entered" ;
$lang['new_execution'] = "Execute a prescription" ;
$lang['execution_entered'] = "Execution entered" ;
?>

View File

@ -839,5 +839,11 @@ $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é"
$lang['one_insured'] = "Assuré";
$lang['new_consultation'] = "Saisir une consultation";
$lang['accident'] = "Accident";
$lang['pregnancy'] = "Soins grossesse";
$lang['consultation_entered'] = "Consultation saisie";
$lang['new_execution'] = "Executer une prescription";
$lang['execution_entered'] = "Execution saisie";
?>

View File

@ -4,7 +4,7 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>iLink | Superviseur</title>
<title>iLink | Agent</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- Bootstrap 3.3.7 -->

View File

@ -23,7 +23,7 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
<section class="content-header">
<h1>
<?php echo $this->lang->line('new_care_sheet') ?>
<?php echo $this->lang->line('new_consultation') ?>
</h1>
</section>
@ -64,6 +64,41 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
<label><?= $this->lang->line('patient_firstname')?></label>
<input class="form-control" name="patient_firstname">
</div>
<div class="form-group row">
<div class="col-md-6">
<div class="form-group">
<label><?= $this->lang->line('accident')?></label>
<input type="checkbox" id="accident-checkbox">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label><?= $this->lang->line('pregnancy')?></label>
<input type="checkbox" id="pregnancy-checkbox">
</div>
</div>
</div>
<div class="form-group" id="accident-div">
<label><?= $this->lang->line('accident_date')?></label>
<input class="form-control" name="accident_date" type="date">
</div>
<div class="form-group row" id="pregnancy-div">
<div class="col-md-6">
<div class="form-group">
<label><?= $this->lang->line('pregnancy_start_at')?></label>
<input class="form-control" name="pregnancy_start_at" type="date">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label><?= $this->lang->line('pregnancy_end_at')?></label>
<input class="form-control" name="pregnancy_end_at" type="date">
</div>
</div>
</div>
</div>
</div>
@ -284,6 +319,25 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
$(document).ready(function (){
$('#patient').hide();
$('#patient-details').hide();
$('#accident-div').hide();
$('#pregnancy-div').hide();
$('#accident-checkbox').change(function() {
if($(this).is(":checked")) {
$('#accident-div').show();
}else{
$('#accident-div').hide();
}
});
$('#pregnancy-checkbox').change(function() {
if($(this).is(":checked")) {
$('#pregnancy-div').show();
}else{
$('#pregnancy-div').hide();
}
});
// Get The Data
const insured = JSON.parse(sessionStorage.getItem('insured'));
if(insured && Array.isArray(insured)){
@ -397,9 +451,17 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
});
indexed_array.beneficiary_id = parseInt(indexed_array.beneficiary_id) === 0 ? null : indexed_array.beneficiary_id;
if (!$('#accident-checkbox').prop('checked')) {
indexed_array.accident_date = null;
}
if (!$('#pregnancy-checkbox').prop('checked')) {
indexed_array.pregnancy_start_at = null;
indexed_array.pregnancy_end_at = null;
}
$.ajax({
url: '<?php echo base_url('NanoHealthController/saveHealthCareSheetConsultation')?>',
url: '<?php echo base_url('NanoHealthController/saveHealthCareSheet/consultation')?>',
type: 'POST',
dataType: 'json',
data: {
@ -410,7 +472,7 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
if(data.status === 200){
Swal.fire({
icon: 'success',
title: "<?= $this->lang->line('drug_and_device_updated')?>",
title: "<?= $this->lang->line('consultation_entered')?>",
text:"<?= $this->lang->line('informations_updated')?>",
timer: 3000
}).then(()=>{
@ -442,6 +504,39 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
return actsOptions;
}
function calculatePrestationsAmount(){
$('#amount').on('input', function () {
var amount = parseFloat($(this).val());
var care_condition = $('#sheet-form').find('select[name="care_condition"]').val();
if(isNaN(amount)){
$('#moderator-ticket').val('');
$('#insurance-amount').val('');
}else{
$.ajax({
url: '<?php echo base_url('NanoHealthController/calculateHealthCareSheetPerformancesAmount')?>',
type: 'POST',
dataType: 'json',
data: {
"network_id" : "<?= $network_id ?>", "amount": amount, "care_condition": care_condition
},
success: function (data) {
if(data.status === 200){
$('#moderator-ticket').val(data.response.moderator_ticket);
$('#insurance-amount').val(data.response.insurance_amount);
}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')?>");
}
});
}
})
}
$('[data-toggle="tooltip"]').tooltip();
var actions1 = $("#prestations td:last-child").html();
@ -460,15 +555,18 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
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" required class="form-control" name="amount" min="0" id="amount"></td>' +
'<td><input class="form-control" name="moderator_ticket" disabled id="moderator-ticket"></td>' +
'<td><input class="form-control" name="insurance_amount" disabled id="insurance-amount"></td>' +
'<td><input type="number" class="form-control" name="home_visit_fees" min="0"></td>' +
'<td> ' + actions1 + '</td>' +
'</tr>';
$("#prestations").append(row);
$("#prestations tbody tr").eq(index + 1).find(".add, .edit").toggle();
$('[data-toggle="tooltip"]').tooltip();
calculatePrestationsAmount();
});
// Add row on add button click
$(document).on("click", ".add1", function () {
@ -504,16 +602,17 @@ $fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
if (index == 0)
$(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" name="amount" min="0" value="' + $(this).text() + '">');
$(this).html('<input type="number" required class="form-control" name="amount" min="0" id="amount" value="' + $(this).text() + '">');
if (index == 2)
$(this).html('<input class="form-control" name="moderator_ticket" disabled value="' + $(this).text() + '">');
$(this).html('<input class="form-control" name="moderator_ticket" disabled id="moderator-ticket" value="' + $(this).text() + '">');
if (index == 3)
$(this).html('<input class="form-control" name="insurance_amount" disabled value="' + $(this).text() + '">');
$(this).html('<input class="form-control" name="insurance_amount" disabled id="insurance-amount" 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");
calculatePrestationsAmount();
});
// Delete row on delete button click
$(document).on("click", ".delete1", function () {

View File

@ -0,0 +1,493 @@
<link rel="stylesheet"
href="<?php echo base_url('bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css') ?>">
<link rel="stylesheet" href="<?php echo base_url('bower_components/bootstrap-daterangepicker/daterangepicker.css') ?>">
<link rel="stylesheet"
href="<?php echo base_url('bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css') ?>">
<link rel="stylesheet" href="<?php echo base_url('bower_components/toastr/toastr.css') ?>">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto|Varela+Round|Open+Sans">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="<?= base_url('dist/css/custom/levels-table.css') ?>">
<?php
use Brick\Money\Context\CustomContext;
use Brick\Money\Money;
$context = new \Brick\Money\Context\AutoContext();
$fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
?>
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<?php echo $this->lang->line('new_execution') ?>
</h1>
</section>
<section class="content">
<div class="row">
<!-- left column -->
<div class="col-md-12">
<!-- general form elements -->
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">Formulaire</h3>
</div>
<!-- /.box-header -->
<!-- form start -->
<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>Consultation</label>
<select class="form-control" name="health_care_sheet_id" required>
<option value="" selected disabled> Choisissez la consultation</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" disabled>
</div>
<div class="form-group">
<label><?= $this->lang->line('patient_firstname')?></label>
<input class="form-control" name="patient_firstname" disabled>
</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" required>
</div>
<div class="form-group">
<label><?= $this->lang->line('practitioner_firstname')?></label>
<input class="form-control" name="practitioner_firstname">
</div>
<div class="form-group">
<label>Classification</label>
<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>
</div>
<div class="form-group mt-2" 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('performances'); ?></label>
</div>
</div>
</div>
<table id="prestations" class="table table-bordered">
<thead>
<tr>
<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>
</tr>
</thead>
<tbody>
</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('exams'); ?></label>
</div>
</div>
</div>
<table id="exams" class="table table-bordered">
<thead>
<tr>
<th><?= $this->lang->line('exam_class'); ?></th>
<th><?= $this->lang->line('exam_description'); ?></th>
<th><?= $this->lang->line('quantity'); ?></th>
<th><?= $this->lang->line('UNIT_PRICE'); ?></th>
<th>Actions</th>
</tr>
</thead>
<tbody>
</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>
</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><?= $this->lang->line('UNIT_PRICE'); ?></th>
<th>Actions</th>
</tr>
</thead>
<tbody>
</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 -->
<div class="box-footer">
<button type="submit" class="btn btn-primary"><?php echo $this->lang->line('save'); ?></button>
<!-- <button type="button" class="btn btn-default pull-left"-->
<!-- data-dismiss="modal">--><?php //echo $this->lang->line('Fermer'); ?><!--</button>-->
</div>
</form>
</div>
<!-- /.box -->
</div>
</div>
</section>
</div>
<!-- jQuery 3 -->
<script src="<?php echo base_url('bower_components/jquery/dist/jquery.min.js') ?>"></script>
<!-- Bootstrap 3.3.7 -->
<script src="<?php echo base_url('bower_components/bootstrap/dist/js/bootstrap.min.js') ?>"></script>
<!-- DataTables -->
<script src="<?php echo base_url('bower_components/datatables.net/js/jquery.dataTables.min.js') ?>"></script>
<script src="<?php echo base_url('bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js') ?>"></script>
<!-- Slimscroll -->
<script src="<?php echo base_url('bower_components/jquery-slimscroll/jquery.slimscroll.min.js') ?>"></script>
<!-- FastClick -->
<script src="<?php echo base_url('bower_components/fastclick/lib/fastclick.js') ?>"></script>
<!-- AdminLTE App -->
<script src="<?php echo base_url('dist/js/adminlte.min.js') ?>"></script>
<!-- AdminLTE for demo purposes -->
<script src="<?php echo base_url('dist/js/demo.js') ?>"></script>
<script src="<?php echo base_url('bower_components/moment/min/moment.min.js') ?>"></script>
<script src="<?php echo base_url('bower_components/bootstrap-daterangepicker/daterangepicker.js') ?>"></script>
<script src="<?php echo base_url('bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js') ?>"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
<!-- ChartJS -->
<script src="<?php echo base_url('bower_components/chart.js/Chart.js') ?>"></script>
<script src="<?php echo base_url('bower_components/toastr/toastr.js') ?>"></script>
<script src="<?php echo base_url('dist/js/sweetalert2.js') ?>"></script>
<script>
toastr.options.closeButton = true;
toastr.options.closeMethod = 'fadeOut';
toastr.options.closeDuration = 5000;
toastr.options.closeEasing = 'swing';
$(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;
var consultations = [];
// 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;
$.ajax({
url: '<?php echo base_url('NanoHealthController/getHealthCareSheets')?>',
type: 'POST',
dataType: 'json',
data: {
"user_id" : item.user.id, "state" : "TO_BILL"
},
success: function (data) {
if(data.status === 200){
consultations = data.response;
$.each(consultations, function (j, it) {
$('#sheet-form').find('select[name="health_care_sheet_id"]').append($('<option>', {
value: it.id,
text : it.health_care_sheet_id +' - '+it.patient_lastname+' '+(it.patient_firstname || '')
}));
});
}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')?>");
}
});
});
$('#patient').show();
});
$('#sheet-form').find('select[name="health_care_sheet_id"]').change(function () {
var val = parseInt($(this).val());
const result = consultations.filter(function(c) {
return c.id === val
});
if(result.length > 0){
const consultation = result[0];
// console.log("selected" , consultation)
$('#sheet-form').find('input[name="patient_lastname"]').val(consultation.patient_lastname || '')
$('#sheet-form').find('input[name="patient_firstname"]').val(consultation.patient_firstname || '')
$("#prestations tbody").children().remove();
$.each(consultation.performances, function (j, it) {
$('#prestations').append('<tr>' +
'<td>'+(it.act.code|| '')+'</td>' +
'<td>'+(it.amount_formatted || '')+'</td>' +
'<td>'+(it.moderator_ticket_formatted || '')+'</td>' +
'<td>'+(it.insurance_amount_formatted || '')+'</td>' +
'<td>'+(it.home_visit_fees_formatted || '')+'</td>' +
'</tr>')
});
const 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';
$("#exams tbody").children().remove();
$.each(consultation.exams, function (j, it) {
$('#exams').append('<tr>' +
'<td id="'+it.id+'">'+(it.act.code|| '')+'</td>' +
'<td>'+(it.description || '')+'</td>' +
'<td>'+(it.quantity || '')+'</td>' +
'<td></td>' +
'<td>'+actions2+'</td>' +
'</tr>')
});
const actions3 = '<a class="add add3" title="Add" data-toggle="tooltip"><i class="material-icons">&#xE03B;</i></a>\n' +
' <a class="edit edit3" title="Edit" data-toggle="tooltip"><i class="material-icons">&#xE254;</i></a>\n';
$("#prescriptions tbody").children().remove();
$.each(consultation.prescriptions, function (j, it) {
$('#prescriptions').append('<tr>' +
'<td id="'+it.id+'">'+(it.drug_or_device.name|| '')+'</td>' +
'<td>'+(it.dosage || '')+'</td>' +
'<td>'+(it.quantity || '')+'</td>' +
'<td></td>' +
'<td>'+actions3+'</td>' +
'</tr>')
});
$('#patient-details').show();
}
});
}else{
history.back()
}
})
$("#sheet-form").submit(function(e){
e.preventDefault();
// Paliers
var exams = [];
var prescriptions = [];
$('#exams tr').has('td').each(function () {
var arrayItem = {};
$('td', $(this)).each(function (index, item) {
if (index === 0)
arrayItem['id'] = $(item).attr('id');
if (index === 3)
arrayItem['unit_price'] = parseFloat($(item).html());
});
if(!isNaN(arrayItem['unit_price'])){
exams.push(arrayItem);
}
});
$('#prescriptions tr').has('td').each(function () {
var arrayItem = {};
$('td', $(this)).each(function (index, item) {
if (index === 0)
arrayItem['id'] = $(item).attr('id');
if (index === 3)
arrayItem['unit_price'] = parseFloat($(item).html());
});
if(!isNaN(arrayItem['unit_price'])){
prescriptions.push(arrayItem);
}
});
if(exams.length === 0 && prescriptions.length === 0){
return toastr.error("Vous devez saisir au moins un exam ou prescription", "<?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'];
});
$.ajax({
url: '<?php echo base_url('NanoHealthController/saveHealthCareSheet/execution')?>',
type: 'POST',
dataType: 'json',
data: {
...indexed_array, "network_agent_id" : "<?= $network_agent_id ?>",
"exams": exams, "prescriptions": prescriptions,
},
success: function (data) {
if(data.status === 200){
Swal.fire({
icon: 'success',
title: "<?= $this->lang->line('execution_entered')?>",
text:"<?= $this->lang->line('informations_updated')?>",
timer: 3000
}).then(()=>{
location.reload();
});
}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')?>");
}
});
});
</script>
<script type="text/javascript">
// Paliers scripts
$(document).ready(function () {
$('[data-toggle="tooltip"]').tooltip();
// Table Examens
// Add row on add button click
$(document).on("click", ".add2", 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();
$(".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", ".edit2", function () {
$(this).parents("tr").find("td:not(:last-child)").each(function (index) {
if (index == 3)
$(this).html('<input class="form-control" name="unit_price" min="1" step="1" required value="' + $(this).text() + '">');
});
$(this).parents("tr").find(".add, .edit").toggle();
$(".new2").attr("disabled", "disabled");
});
// Table prescription
// Table prescriptions
var actions3 = $("#prescriptions td:last-child").html();
// 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 == 3)
$(this).html('<input type="number" required class="form-control" name="unit_price" required min="1" step="1" value="' + $(this).text() + '">');
});
$(this).parents("tr").find(".add, .edit").toggle();
$(".new3").attr("disabled", "disabled");
});
});
</script>

View File

@ -44,9 +44,14 @@
<div class="box-header">
<h3 class="box-title"><?= $this->lang->line('export_health_care_sheets_list') ?></h3>
<div class="box-tools">
<button class="btn btn-success" data-toggle="modal" data-target="#modal-add">
<?= $this->lang->line('new_care_sheet'); ?>
<?php if(!empty($show_health_care_sheet_buttons)) { ?>
<button class="btn btn-success" id="new-consultation" data-toggle="modal" data-target="#modal-add-consultation">
<?= $this->lang->line('new_consultation'); ?>
</button>
<button class="btn btn-primary" id="new-execution" data-toggle="modal" data-target="#modal-add-execution">
<?= $this->lang->line('new_execution'); ?>
</button>
<?php } ?>
</div>
</div>
<div class="box-body" style="overflow-x:auto;">
@ -73,14 +78,14 @@
</div>
</div>
<div class="modal fade" id="modal-add">
<div class="modal fade" id="modal">
<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>
<h3 class="modal-title" id="modal-title"></h3>
</div>
<div class="modal-body">
<form id="search-form">
@ -244,6 +249,20 @@
</script>
<script>
var action = "";
$('#new-consultation').click(function () {
action = "new_consultation";
$('#modal-title').html("<?= $this->lang->line('new_consultation'); ?>")
$('#modal').modal('show');
})
$('#new-execution').click(function () {
action = "new_execution";
$('#modal-title').html("<?= $this->lang->line('new_execution'); ?>")
$('#modal').modal('show');
})
$('#check-insured').click(function () {
if ($('#search-form')[0].checkValidity()) {
let option = $('#search-form').find('select[name="option"]').val();
@ -260,7 +279,7 @@
}else{
// Set data
sessionStorage.setItem('insured' , JSON.stringify(data.response));
window.location = '<?= current_url().('?action=new')?>';
window.location = '<?= current_url().('?action=')?>'+action;
}
}else{
toastr.error(data.error , "<?= $this->lang->line('request_error')?>");