<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}ABXBMI{% endblock %}</title>
{# <link rel="icon" href="{{ asset('build/img/icon1024.png') }}"></link> #}
<link rel="icon" type="image.png" sizes="32x32" href="{{ asset('build/img/favicon-32x32.png') }}">
<link rel="icon" type="image.png" sizes="16x16" href="{{ asset('build/img/favicon-16x16.png') }}">
<link rel="apple-touch-icon" sizes="180x180" href="{{ asset('build/img/faviconIphone.png') }}">
{# Run `composer require symfony/webpack-encore-bundle` to start using Symfony UX #}
{% block stylesheets %}
{{ encore_entry_link_tags('app') }}
{% endblock %}
{# <link rel="stylesheet" href="..\assets\styles\app.css"></link> #}
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<style>
.autocomplete-container {
position: relative;
}
.autocomplete-suggestions {
position: absolute;
top: 100%;
left: 0;
right: 0;
z-index: 1020;
background-color: #ffffff;
border: 1px solid #ced4da;
border-top: none;
max-height: 200px;
overflow-y: auto;
display: none;
}
.autocomplete-item {
display: block;
width: 100%;
padding: 6px 12px;
text-align: left;
background: transparent;
border: none;
border-bottom: 1px solid #e9ecef;
cursor: pointer;
}
.autocomplete-item:last-child {
border-bottom: none;
}
.autocomplete-item.active,
.autocomplete-item:hover,
.autocomplete-item:focus {
background-color: #f2f6ff;
outline: none;
}
</style>
{% block javascripts %}
{{ encore_entry_script_tags('app') }}
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-RTG28H3XZF"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'G-RTG28H3XZF');
</script>
<script src="{{ asset('bundles/fosjsrouting/js/router.js') }}"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>
<script>
const accentReplacements = {
'\u00e0': 'a',
'\u00e1': 'a',
'\u00e2': 'a',
'\u00e3': 'a',
'\u00e4': 'a',
'\u00e5': 'a',
'\u00e6': 'ae',
'\u00e7': 'c',
'\u00e8': 'e',
'\u00e9': 'e',
'\u00ea': 'e',
'\u00eb': 'e',
'\u00ec': 'i',
'\u00ed': 'i',
'\u00ee': 'i',
'\u00ef': 'i',
'\u00f1': 'n',
'\u00f2': 'o',
'\u00f3': 'o',
'\u00f4': 'o',
'\u00f5': 'o',
'\u00f6': 'o',
'\u00f8': 'o',
'\u0153': 'oe',
'\u00f9': 'u',
'\u00fa': 'u',
'\u00fb': 'u',
'\u00fc': 'u',
'\u00fd': 'y',
'\u00ff': 'y',
'\u00df': 'ss'
};
$( document ).ready(function() {
document.getElementById('calcPatient').style.height = 'calc(100% - (' + document.getElementById('titrePatient').offsetHeight + 'px + ' + $('#titrePatient').css('margin-top') +' + ' + $('#titrePatient').css('margin-bottom') + ' + ' + $('#calcPatient').css('margin-bottom') + ' + ' + $('#calcPatient').css('border-bottom-width') + ' + ' + $('#calcPatient').css('border-top-width') + '))';
document.getElementById('calcPrescription').style.height = 'calc(100% - (' + document.getElementById('titrePrescription').offsetHeight + 'px + ' + $('#titrePrescription').css('margin-top') +' + ' + $('#titrePrescription').css('margin-bottom') + ' + ' + $('#calcPrescription').css('margin-bottom') + ' + ' + $('#calcPrescription').css('border-bottom-width') + ' + ' + $('#calcPrescription').css('border-top-width') + '))';
var antibioInput = document.getElementById('antibioEntry');
var antibioSuggestions = document.getElementById('antibioSuggestions');
var antibioAutocomplete = document.getElementById('antibioAutocomplete');
if (antibioInput && antibioSuggestions && antibioAutocomplete && antibioInput.tagName === 'INPUT' && antibioInput.dataset.antibiotiques) {
const antibios = JSON.parse(antibioInput.dataset.antibiotiques);
const normalizedAntibios = antibios.map(function(label) {
return {
label: label,
normalized: normalizeAntibiotic(label)
};
});
var currentSuggestions = [];
var activeSuggestionIndex = -1;
const clearSuggestions = function() {
antibioSuggestions.innerHTML = '';
antibioSuggestions.style.display = 'none';
currentSuggestions = [];
activeSuggestionIndex = -1;
};
const highlightSuggestion = function(index) {
var items = antibioSuggestions.querySelectorAll('.autocomplete-item');
if (!items.length) {
return;
}
items.forEach(function(item, itemIndex) {
if (itemIndex === index) {
item.classList.add('active');
item.scrollIntoView({ block: 'nearest' });
} else {
item.classList.remove('active');
}
});
activeSuggestionIndex = index;
};
const applySuggestion = function(item) {
antibioInput.value = item.label;
clearSuggestions();
checkATB();
};
const renderSuggestions = function(filterValue) {
const normalizedFilter = normalizeAntibiotic(filterValue.trim());
antibioSuggestions.innerHTML = '';
currentSuggestions = [];
activeSuggestionIndex = -1;
var candidateSuggestions;
if (normalizedFilter === '') {
candidateSuggestions = normalizedAntibios;
} else {
candidateSuggestions = normalizedAntibios.filter(function(item) {
return item.normalized.includes(normalizedFilter);
});
}
if (!candidateSuggestions.length) {
clearSuggestions();
return;
}
candidateSuggestions.forEach(function(item) {
var suggestionIndex = currentSuggestions.length;
var button = document.createElement('button');
button.type = 'button';
button.className = 'autocomplete-item';
button.textContent = item.label;
button.addEventListener('mouseenter', function() {
highlightSuggestion(suggestionIndex);
});
button.addEventListener('mousedown', function(event) {
event.preventDefault();
applySuggestion(item);
});
antibioSuggestions.appendChild(button);
currentSuggestions.push(item);
});
if (currentSuggestions.length) {
antibioSuggestions.style.display = 'block';
} else {
clearSuggestions();
}
};
antibioInput.addEventListener('input', function(event) {
renderSuggestions(event.target.value);
});
antibioInput.addEventListener('focus', function(event) {
renderSuggestions(event.target.value);
});
antibioInput.addEventListener('keydown', function(event) {
if (!currentSuggestions.length) {
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
renderSuggestions(antibioInput.value);
}
return;
}
if (event.key === 'ArrowDown') {
event.preventDefault();
var nextIndex = (activeSuggestionIndex + 1) % currentSuggestions.length;
highlightSuggestion(nextIndex);
} else if (event.key === 'ArrowUp') {
event.preventDefault();
var previousIndex = activeSuggestionIndex <= 0 ? currentSuggestions.length - 1 : activeSuggestionIndex - 1;
highlightSuggestion(previousIndex);
} else if (event.key === 'Enter') {
if (activeSuggestionIndex >= 0 && activeSuggestionIndex < currentSuggestions.length) {
event.preventDefault();
applySuggestion(currentSuggestions[activeSuggestionIndex]);
}
} else if (event.key === 'Escape') {
clearSuggestions();
}
});
antibioInput.addEventListener('blur', function() {
setTimeout(function() {
clearSuggestions();
}, 150);
});
document.addEventListener('click', function(event) {
if (!antibioAutocomplete.contains(event.target)) {
clearSuggestions();
}
});
}
});
window.addEventListener('resize', function(event) {
document.getElementById('calcPatient').style.height = 'calc(100% - (' + document.getElementById('titrePatient').offsetHeight + 'px + ' + $('#titrePatient').css('margin-top') +' + ' + $('#titrePatient').css('margin-bottom') + ' + ' + $('#calcPatient').css('margin-bottom') + ' + ' + $('#calcPatient').css('border-bottom-width') + ' + ' + $('#calcPatient').css('border-top-width') + '))';
document.getElementById('calcPrescription').style.height = 'calc(100% - (' + document.getElementById('titrePrescription').offsetHeight + 'px + ' + $('#titrePrescription').css('margin-top') +' + ' + $('#titrePrescription').css('margin-bottom') + ' + ' + $('#calcPrescription').css('margin-bottom') + ' + ' + $('#calcPrescription').css('border-bottom-width') + ' + ' + $('#calcPrescription').css('border-top-width') + '))';
}, true);
function concatUrl(base, path) {
return base.replace(/\/+$/, '') + '/' + path.replace(/^\/+/, '');
}
function disableText() {
var radio = document.getElementById("mgkgj");
var text = document.getElementById("mgkgjEntry");
text.disabled = !radio.checked;
var text2 = document.getElementById("mgkgdoseEntry");
text2.disabled = true;
text2.value = '';
}
function disableText2() {
var radio = document.getElementById("mgkgdose");
var text = document.getElementById("mgkgdoseEntry");
text.disabled = !radio.checked;
var text2 = document.getElementById("mgkgjEntry");
text2.disabled = true;
text2.value = '';
}
function normalizeAntibiotic(value) {
if (!value) {
return '';
}
var text = value.toString();
if (typeof text.normalize === 'function') {
text = text.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
}
text = text.toLowerCase();
return text.replace(/[^\u0000-\u007E]/g, function(character) {
return accentReplacements[character] || character;
});
}
function checkATB(){
document.getElementById("doseStandard").innerHTML = "";
var match = false;
var entry = document.getElementById("antibioEntry");
const antibios = JSON.parse(entry.dataset.antibiotiques);
var texte = entry.value.trim();
var texteNormalise = normalizeAntibiotic(texte);
document.getElementById("recommandationDiv").style.display = "none";
document.getElementById("noRecommandationDiv").style.display = "none";
var newDivLoader = document.getElementById('loader').cloneNode(true);
document.getElementById('doseStandard').appendChild(newDivLoader);
document.getElementById('doseStandard').style.display = "block";
newDivLoader.style.display = 'block';
for (let i = 0; i <= antibios.length - 1; i++){
var antibioCourant = antibios[i];
if(texteNormalise !== '' && normalizeAntibiotic(antibioCourant) === texteNormalise){
let url = new URL("{{ path('checkatb', {'_locale': app.request.locale})|e('js') }}", window.location.origin);
url.searchParams.set('antibiotique', antibioCourant);
fetch(url.toString())
.then(response => response.json())
.then(data => {
document.getElementById('doseStandard').innerHTML = data.content;
newDivLoader.style.display = 'none';
})
.catch(error => {
console.log("error :", error);
newDivLoader.style.display = 'none';
});
match = true;
entry.value = antibioCourant;
break;
}else if (match == false){
if(i == antibios.length - 1){
document.getElementById('doseStandard').style.display = 'none';
}
}
}
}
function calculCliked(){
document.getElementById("recommandationDiv").style.display = "none";
document.getElementById("noRecommandationDiv").style.display = "none";
var newDivLoader = document.getElementById('loader').cloneNode(true);
document.getElementById('recomandationBlock').appendChild(newDivLoader);
newDivLoader.style.display = 'block';
var antibioVal = document.getElementById("antibioEntry").value;
var sexeVal = document.getElementById("sexeSelect").value;
var poidsVal = document.getElementById("poidsEntry").value;
var tailleVal = document.getElementById("tailleEntry").value;
var doseVal = (document.getElementById("mgkgjEntry").value == '') ? (document.getElementById("mgkgdoseEntry").value) : (document.getElementById("mgkgjEntry").value);
if(antibioVal != '' && antibioVal != null ){
if(sexeVal == 1 || sexeVal == 2){
if(poidsVal != '' && poidsVal != null && poidsVal != 0){
if(tailleVal != '' && tailleVal != null && tailleVal != 0){
if(doseVal != '' && doseVal != null && doseVal != 0){
let url = new URL("{{ path('calcul', {'_locale': app.request.locale})|e('js') }}", window.location.origin);
url.searchParams.set('antibiotique', antibioVal);
url.searchParams.set('sexe', sexeVal);
url.searchParams.set('poids', poidsVal);
url.searchParams.set('taille', tailleVal);
url.searchParams.set('dose', doseVal);
fetch(url.toString())
.then(response => response.json())
.then(data => {
document.getElementById("recommandationDiv").style.display = "none";
document.getElementById("noRecommandationDiv").style.display = "none";
if(data.content == "Aucun calcul pour cet antibiotique."){
newDivLoader.style.display = 'none';
document.getElementById("noRecommandationDiv").style.display = "block";
}else{
document.getElementById('bmiClient').innerHTML = data.content.datas.situation_bmi;
let recommandation = 'let abw = ' + data.content.datas.abw +';let bmi = ' + data.content.datas.bmi +';let dose =' + data.content.datas.dose + ';let ibw = ' + data.content.datas.ibw +';let interpretation_bmi = "' + data.content.datas.interpretation_bmi +'";let lbw = ' + data.content.datas.lbw +';let libelleAntibiotique = "' + data.content.datas.libelleAntibiotique + '";let libelleFamilleAntibiotique = "' + data.content.datas.libelleFamilleAntibiotique + '";let poids = ' + data.content.datas.poids +';let sexe = ' + data.content.datas.sexe +';let situation = "' + data.content.datas.situation + '";let situation_bmi = "' + data.content.datas.situation_bmi + '";let taille = '+ data.content.datas.taille + ';let x_abw = '+ data.content.datas.x_abw + ';' + data.content.datas.recommandation.replace(/\t/g, "").replace(/\n/g, "").replace(/\"/g, '"');
let func = new Function(recommandation);
func();
document.getElementById('bmiClient').innerHTML = data.content.datas.situation_bmi;
document.getElementById('referencesChild').innerHTML = data.content.datas.reference;
newDivLoader.style.display = 'none';
document.getElementById("recommandationDiv").style.display = "block";
}
})
.catch(error => {
console.log("error :", error);
newDivLoader.style.display = 'none';
});
}else{
if(document.getElementById("mgkgj").checked){
newDivLoader.style.display = 'none';
document.getElementById("modelText").innerHTML = "{{ 'labels.errors.mg/kg/j'|trans|e('js') }}";
$("#modal").modal('show');
}else if (document.getElementById("mgkgdose").checked){
newDivLoader.style.display = 'none';
document.getElementById("modelText").innerHTML = "{{ 'labels.errors.mg/kg/dose'|trans|e('js') }}";
$("#modal").modal('show');
}else{
newDivLoader.style.display = 'none';
document.getElementById("modelText").innerHTML = "{{ 'labels.errors.dose'|trans|e('js') }}";
$("#modal").modal('show');
}
}
}else{
newDivLoader.style.display = 'none';
document.getElementById("modelText").innerHTML = "{{ 'labels.errors.height'|trans|e('js') }}";
$("#modal").modal('show');
}
}else{
newDivLoader.style.display = 'none';
document.getElementById("modelText").innerHTML = "{{ 'labels.errors.weight'|trans|e('js') }}";
$("#modal").modal('show');
}
}else{
newDivLoader.style.display = 'none';
document.getElementById("modelText").innerHTML = "{{ 'labels.errors.sexe'|trans|e('js') }}";
$("#modal").modal('show');
}
}else{
newDivLoader.style.display = 'none';
document.getElementById("modelText").innerHTML = "{{ 'labels.errors.antb'|trans|e('js') }}";
$("#modal").modal('show');
}
}
</script>
{% endblock %}
</head>
<body>
<div id="loader" style="display: none;">
<div style="text-align: center; justify-content: center; display: flex;">
<div style="border: 16px solid #cd3c3e; border-top: 16px solid #fff; border-radius: 50%; width: 120px; height: 120px; animation: spin 2s linear infinite;"></div>
</div>
</div>
<div id="content">
{% set currentLocale = app.request.locale %}
{# --------------------------------------------------- HEADER ---------------------------------------------------#}
{% include 'include/header.html.twig' %}
{# --------------------------------------------------- HEADER ---------------------------------------------------#}
<div class="container">
<div id="calcul">
<div id="patient">
<p id="titrePatient" class="titreForm"><strong>{{ 'labels.patient'|trans }}</strong></p>
<div id="calcPatient" class="form1">
{# Sexe #}
<div class="form">
<p class='sousTitreForm'>{{ 'labels.sex'|trans }}</p>
<select name="sexe" id="sexeSelect">
<option value="1">{{ 'sex.man'|trans }}</option>
<option value="2">{{ 'sex.woman'|trans }}</option>
</select>
</div>
{# Poids #}
<div class="form">
<p class='sousTitreForm'>{{ 'labels.weight'|trans }}</p>
<input type="number" id="poidsEntry"></input>
</div>
{# Taille #}
<div class="form">
<p class='sousTitreForm'>{{ 'labels.height'|trans }}</p>
<input type="number" id="tailleEntry"></input>
</div>
</div>
</div>
<div id="prescription">
<p id="titrePrescription" class="titreForm"><strong>{{ 'labels.prescription'|trans }}</strong></p>
<div id="calcPrescription" class="form1">
<div id="atbEntry" class="form">
{# {% if antibiogarde == 1 %}
<select id="antibioEntry" data-antibiotiques='{{ antibiotiques|json_encode() }}' onchange="checkATB();">
<option>{{ 'labels.selectAtb'|trans }}</option>
{% for option in antibiotiques %}
<option>{{ option|raw }}</option>
{% endfor %}
</select>
{% else %} #}
<div id="antibioAutocomplete" class="autocomplete-container">
<input type="search" id="antibioEntry" placeholder="{{ 'labels.antibiotiques'|trans }}" autocomplete="off" data-antibiotiques='{{ antibiotiques|json_encode() }}' onchange="checkATB();"></input>
<div id="antibioSuggestions" class="autocomplete-suggestions"></div>
</div>
{# {% endif %} #}
</div>
<div class="form">
<p style="margin:0; margin-bottom: 0;">{{ 'labels.standardDose'|trans }}</p>
{# equivalence vie BDD #}
<strong>
<div id="doseStandard">
</div>
</strong>
</div>
<div class="form">
<p style="margin:0; margin-bottom: 0;">{{ 'labels.givenDosage'|trans }}</p>
<div id="radioDiv" class="container">
<div style="margin: 10px;">
<div>
<input type="radio" id="mgkgj" name="drone" value="mgkgj" onchange="disableText()">
<label for="mgkgj">{{ 'labels.mg/kg/j'|trans }}</label>
</div>
<input type="number" id="mgkgjEntry" disabled></input>
</div>
<div style="margin: 10px;">
<div>
<input type="radio" id="mgkgdose" name="drone" value="mgkgdose" onchange="disableText2()">
<label for="mgkgdose">{{ 'labels.mg/kg/dose'|trans }}</label>
</div>
<input type="number" id="mgkgdoseEntry" disabled></input>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="bouttonCalcul">
<button type="button" id="btnCalc" onClick="calculCliked();"><strong>{{ 'answer.recommendationTitle'|trans }}</strong></button>
</div>
<div id="recomandationBlock">
<div id="recommandationDiv">
<div id="reco">
<p style="margin:0; margin-bottom: 0;"><strong>{{ 'answer.recommandation'|trans }}</strong></p>
</div>
<div style="padding: 20px;">
<div>
<p style="margin:0; margin-bottom: 0;" id="bmiClient"></p>
</div>
<div style="padding-top: 20px;">
<p style="margin:0; margin-bottom: 0;" id="recommandation"></p>
</div>
<div style="padding-top: 20px;">
{# conseil recup en BDD #}
<p style="margin:0; margin-bottom: 0;" id="adaptation_poso"></p>
</div>
<div id="references" style="padding-top: 20px;">
<p style="margin:0; margin-bottom: 0;" id="ref"><strong>{{ 'answer.references'|trans }}</strong></p>
{# boucle for reach sur les références dispo en BDD #}
<div id="referencesChild">
{# en js ajoute des enfants avec les références #}
</div>
</div>
</div>
</div>
<div id="noRecommandationDiv">
{{ 'answer.noCalcul'|trans }}
</div>
</div>
</div>
</div>
{# --------------------------------------------------- ------ ---------------------------------------------------#}
{# --------------------------------------------------- FOOTER ---------------------------------------------------#}
{# --------------------------------------------------- ------ ---------------------------------------------------#}
{% include 'include/footer.html.twig' %}
<!-- Modal -->
<div id="modal" class="modal fade" id="staticBackdrop" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="staticBackdropLabel">{{ 'modal.attention'|trans }}</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p id="modelText"></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{{ 'modal.ok'|trans }}</button>
</div>
</div>
</div>
</div>
</body>
</html>