|
@@ -29,4 +29,71 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
+ <script>
|
|
|
+ (function () {
|
|
|
+ function calculateUsualBmi() {
|
|
|
+ let h = $('#bmi-management-settings [name="currentHeightInInches"]').val(),
|
|
|
+ w = $('#bmi-management-settings [name="usualWeightInPounds"]').val();
|
|
|
+ let bmiElem = $('#bmi-management-settings [name="usualBmi"]').val(''),
|
|
|
+ bmiCategoryElem = $('#bmi-management-settings [name="usualBmiCategory"]').val('');
|
|
|
+ calculateBmi(h, w, bmiElem, bmiCategoryElem);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ function calculateIdealBmi() {
|
|
|
+ let h = $('#bmi-management-settings [name="currentHeightInInches"]').val(),
|
|
|
+ w = $('#bmi-management-settings [name="idealWeightInPounds"]').val();
|
|
|
+ let bmiElem = $('#bmi-management-settings [name="idealBmi"]').val(''),
|
|
|
+ bmiCategoryElem = $('#bmi-management-settings [name="idealBmiCategory"]').val('');
|
|
|
+ calculateBmi(h, w, bmiElem, bmiCategoryElem);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ function calculateBmi(h, w, bmiElem, bmiCategoryElem) {
|
|
|
+ let bmi = 0,
|
|
|
+ bmiCategory = '';
|
|
|
+ try {
|
|
|
+ h = +h;
|
|
|
+ w = +w;
|
|
|
+ bmi = (w / (h * h)) * 703;
|
|
|
+ bmiElem.val(bmi.toFixed(1));
|
|
|
+ if (bmi < 18.5) {
|
|
|
+ bmiCategory = '(Underweight)';
|
|
|
+ }
|
|
|
+ if (bmi >= 18.5 && bmi < 25) {
|
|
|
+ bmiCategory = '(Healthy)';
|
|
|
+ }
|
|
|
+ if (bmi >= 25 && bmi < 30) {
|
|
|
+ bmiCategory = '(Overweight)';
|
|
|
+ }
|
|
|
+ if (bmi >= 30) {
|
|
|
+ bmiCategory = '(Obese)';
|
|
|
+ }
|
|
|
+ bmiCategoryElem.val(bmiCategory);
|
|
|
+ } catch (e) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function init() {
|
|
|
+ $(document)
|
|
|
+ .off('change input paste keyup',
|
|
|
+ '#bmi-management-settings [name="currentHeightInInches"], #bmi-management-settings [name="usualWeightInPounds"]')
|
|
|
+ .on('change input paste keyup',
|
|
|
+ '#bmi-management-settings [name="currentHeightInInches"], #bmi-management-settings [name="usualWeightInPounds"]', function () {
|
|
|
+ return calculateUsualBmi();
|
|
|
+ });
|
|
|
+ $(document)
|
|
|
+ .off('change input paste keyup',
|
|
|
+ '#bmi-management-settings [name="currentHeightInInches"], #bmi-management-settings [name="idealWeightInPounds"]')
|
|
|
+ .on('change input paste keyup',
|
|
|
+ '#bmi-management-settings [name="currentHeightInInches"], #bmi-management-settings [name="idealWeightInPounds"]', function () {
|
|
|
+ return calculateIdealBmi();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ addMCInitializer('vitals-settings-{{$patient->uid}}', init, '#vitals-settings-{{$patient->uid}}')
|
|
|
+ }).call(window);
|
|
|
+ </script>
|
|
|
+
|
|
|
@endsection
|