Peter Muturi 3 жил өмнө
parent
commit
5b831043e6

+ 3 - 3
public/css/style.css

@@ -115,7 +115,7 @@ main {
   gap: 10px;
 }
 .flex-header >div {
-  flex-grow: 1;
+  /* flex-grow: 1; */
 }
 .patient-header-address {
   list-style-type: none;
@@ -3449,7 +3449,7 @@ body.forced-masking #mask {
 .mcp-theme-1 .point-table [if-read-mode] .inline-html-container {
     cursor: pointer;
 }
-table.v-top td, 
+table.v-top td,
 table.v-top th {
     vertical-align:top;
 }
@@ -3482,4 +3482,4 @@ table.v-top th {
     overflow: hidden;
     text-overflow: ellipsis;
     display: inline-block;
-}
+}

+ 142 - 0
public/js/dq0.js

@@ -0,0 +1,142 @@
+(function() {
+    window.initDQ = function() {
+        $(document)
+            .off('change input paste', '.dq-edit-container input, .dq-edit-container textarea, .dq-edit-container select')
+            .on('change input paste', '.dq-edit-container input, .dq-edit-container textarea, .dq-edit-container select', function() {
+                let key = $(this).closest('.dq-line').attr('dq-key'),
+                    dataElem = $(this).closest('.dq-edit-container').find('>.dq-data-map').first(),
+                    current = JSON.parse(dataElem.text());
+                current[key] = $(this).val();
+                let serialized = JSON.stringify(current);
+                dataElem.text(serialized);
+                $(this).closest('form').find('input[name="data"]').val(serialized);
+                let fullData = {
+                    lines: JSON.parse($(this).closest('.dq-edit-container').find('>.dq-definition').first().text()),
+                    dataMap: current
+                };
+                $(this).closest('form').find('input[name="data"]').val(JSON.stringify(fullData));
+
+                runDQConditions($(this).closest('.dq-edit-container'));
+            });
+        $(document)
+            .off('input.auto-grow', '.dq-edit-container textarea')
+            .on('input.auto-grow', '.dq-edit-container textarea', function() {
+                this.style.minHeight = "calc(1.5em + .5rem + 2px)";
+                this.style.height = "calc(1.5em + .5rem + 2px)";
+                this.style.height = (this.scrollHeight)+"px";
+            });
+    };
+
+    function resolveAtomicCondition(_condition, _dataMap) {
+        if(!_condition.hasOwnProperty('key') || !_condition.hasOwnProperty('value')) {
+            _condition.resolution = false;
+            return;
+        }
+        let key = _condition.key, op = _condition.hasOwnProperty('op') ? _condition.op : 'eq';
+        let lhs = _dataMap[key], rhs = _condition.value;
+        switch(op) {
+            case 'eq':
+                _condition.resolution = (lhs == rhs); // NOTE: using == instead of === on purpose
+                break;
+            case 'lt':
+                _condition.resolution = (+lhs < +rhs);
+                break;
+            case 'lte':
+                _condition.resolution = (+lhs <= +rhs);
+                break;
+            case 'gt':
+                _condition.resolution = (+lhs > +rhs);
+                break;
+            case 'gte':
+                _condition.resolution = (+lhs >= +rhs);
+                break;
+            default:
+                _condition.resolution = false;
+        }
+    }
+
+    function resolveAllAtomicConditions(_conditions, _dataMap) {
+        if(Array.isArray(_conditions)) {
+            for (let i = 0; i < _conditions.length; i++) {
+                resolveAllAtomicConditions(_conditions[i], _dataMap);
+            }
+        }
+        else if(typeof _conditions === 'object') {
+            resolveAtomicCondition(_conditions, _dataMap);
+        }
+    }
+
+    function reduceConditionsIntoResolutions(_conditions) {
+        for (let i = 0; i < _conditions.length; i++) {
+            // if simple object, resolve
+            if(!Array.isArray(_conditions[i]) && typeof _conditions[i] === 'object') {
+                _conditions.splice(i, 1, _conditions[i].resolution);
+            }
+            else if(Array.isArray(_conditions[i])) {
+                reduceConditionsIntoResolutions(_conditions[i]);
+            }
+        }
+    }
+
+    function combineResolutionListsIntoSingleResolutions(_conditions) {
+        console.log('ALIX 1', _conditions);
+        for (let i = 0; i < _conditions.length; i++) {
+            if(Array.isArray(_conditions[i])) {
+                _conditions[i] = combineResolutionListsIntoSingleResolutions(_conditions[i]);
+            }
+        }
+        console.log('ALIX 2', _conditions);
+
+        // at this point, the array will have only booleans and "AND", "OR" combinators
+        let resolution = _conditions[0];
+        for (let i = 1; i < _conditions.length; i+=2) {
+            if(_conditions[i] === 'AND') {
+                resolution = resolution && _conditions[i + 1];
+            }
+            else if(_conditions[i] === 'OR') {
+                resolution = resolution || _conditions[i + 1];
+            }
+        }
+
+        return resolution;
+    }
+
+    window.runDQConditions = function(_parent) {
+
+        _parent.find('.dq-line.has-pre-condition').each(function() {
+            let conditions = JSON.parse($(this).find('>.dq-pre-condition').first().text()),
+                dataMap = JSON.parse($(this).closest('.dq-edit-container').find('>.dq-data-map').first().text());
+
+            resolveAllAtomicConditions(conditions, dataMap);
+
+            // if object, single condition with key, op and value
+            if(!Array.isArray(conditions) && typeof conditions === 'object') {
+                if(conditions.resolution) {
+                    $(this).removeClass('d-none');
+                }
+                else {
+                    $(this).addClass('d-none');
+                }
+            }
+            // else if array - means list of conditions with 'and' or 'or' separators - array size MUST be an odd number
+            else if(Array.isArray(conditions)) {
+
+                // goal is to reduce each item in the array into a single boolean - recursively
+                reduceConditionsIntoResolutions(conditions);
+
+                conditions = combineResolutionListsIntoSingleResolutions(conditions);
+
+                if(conditions) {
+                    $(this).removeClass('d-none');
+                }
+                else {
+                    $(this).addClass('d-none');
+                }
+
+            }
+
+        });
+
+    }
+    addMCInitializer('dq-edit', initDQ, '.dq-edit-container');
+}).call(window);

+ 49 - 0
public/js/stag-collapsible-card1.js

@@ -0,0 +1,49 @@
+(function() {
+    function init() {
+        $('.card[stag-collapsible-card]:not([stag-collapsible-card-initialized])').each(function() {
+            let header = $(this).find('>.card-header').first();
+            if(header.length) {
+                let html = header.html();
+                let newHeader = $('<div class="d-flex align-items-center"></div>');
+                newHeader.append(html);
+                let collapseTrigger = $('<a href="#" class="stag-collapse-trigger ml-auto" />');
+                collapseTrigger.append('<i class="fa fa-chevron-up if-not-collapsed"/>');
+                collapseTrigger.append('<i class="fa fa-chevron-down if-collapsed"/>');
+                newHeader.append(collapseTrigger);
+                header
+                    .empty()
+                    .append(newHeader);
+            }
+            if(!!$(this).attr('stag-collapsible-card')) {
+                let state = localStorage['collapseState_' + $(this).attr('stag-collapsible-card')];
+                if(state === 'collapsed') {
+                    $(this).attr('collapsed', 1);
+                }
+                else if(state === 'not-collapsed') {
+                    $(this).removeAttr('collapsed');
+                }
+            }
+            $(this).attr('stag-collapsible-card-initialized', 1);
+        });
+
+        $(document)
+            .off('click.stag-collapse-toggle', '.card[stag-collapsible-card][stag-collapsible-card-initialized] .stag-collapse-trigger')
+            .on('click.stag-collapse-toggle', '.card[stag-collapsible-card][stag-collapsible-card-initialized] .stag-collapse-trigger', function() {
+                let card = $(this).closest('.card');
+                if(card.is('[collapsed]')) {
+                    card.removeAttr('collapsed');
+                    if(!!card.attr('stag-collapsible-card')) {
+                        localStorage['collapseState_' + card.attr('stag-collapsible-card')] = 'not-collapsed';
+                    }
+                }
+                else {
+                    card.attr('collapsed', 1);
+                    if(!!card.attr('stag-collapsible-card')) {
+                        localStorage['collapseState_' + card.attr('stag-collapsible-card')] = 'collapsed';
+                    }
+                }
+                return false;
+            });
+    }
+    addMCInitializer('stag-collapsible-card', init);
+}).call(window);

+ 66 - 0
public/js/stag-table-filter1.js

@@ -0,0 +1,66 @@
+(function () {
+    window.initStagTableFilters = function () {
+
+        const debounce = (func, wait) => {
+            let timeout;
+            return function executedFunction(...args) {
+                const later = () => {
+                    clearTimeout(timeout);
+                    func(...args);
+                };
+                clearTimeout(timeout);
+                timeout = setTimeout(later, wait);
+            };
+        };
+
+        var returnedFunction = debounce(function (_elem) {
+            let term = $.trim(_elem.val()).toLowerCase(),
+                columnIndex = _elem.closest('td, th').index(),
+                trs = _elem.closest('table').find('tbody').find('tr');
+            trs.removeClass('stag-filter-hide');
+            trs.find('.stag-filter-highlight').replaceWith(function() {
+                return $(this).text();
+            });
+            _elem.closest('td, th').siblings().find('input[stag-table-filter]').val('');
+            if(!!term) {
+                trs.each(function () {
+                    let td = $(this).find('td:eq(' + columnIndex + ')'),
+                        text = td.text();
+                    if (text.toLowerCase().indexOf(term) === -1) {
+                        $(this).addClass('stag-filter-hide');
+                    }
+                    /*else {
+                        let re = new RegExp('(' + term + ')', 'ig');
+                        text = text.replace(re, '<span class="stag-filter-highlight">$&</span>');
+                        td.html(text);
+                    }*/
+                });
+            }
+        }, 100);
+
+        function applyFilter(_elem) {
+            returnedFunction(_elem);
+        }
+
+        $(document)
+            .off('input.stag-table-filter').on('input.stag-table-filter', 'input[stag-table-filter]', function() { applyFilter($(this)); })
+            .off('change.stag-table-filter').on('change.stag-table-filter', 'input[stag-table-filter]', function() { applyFilter($(this)); })
+            .off('paste.stag-table-filter').on('paste.stag-table-filter', 'input[stag-table-filter]', function() { applyFilter($(this)); })
+
+        $(document)
+            .off('keyup.stag-table-filter')
+            .on('keyup.stag-table-filter', 'input[stag-table-filter]', function(_e) {
+                if(_e.which === 27) {
+                    if(!isEventConsumed(e)) {
+                        if ($(this).val() !== '') {
+                            $(this).val('');
+                            applyFilter($(this));
+                            markEventAsConsumed(_e);
+                            return false;
+                        }
+                    }
+                }
+            })
+    }
+    addMCInitializer('stag-table-filter', window.initStagTableFilters);
+})();

+ 1 - 1
resources/views/layouts/patient-header.blade.php

@@ -485,7 +485,7 @@ $addressParts .= implode(", ", $addressPart2);
       @endif
     </div>
 
-    <div class="bg-light p-2 border" style="max-width: 215px;">
+    <div class="bg-light p-2 border ml-auto" style="max-width: 215px;">
       <div>
         <div class="d-flex">
           <label class="">Sticky Note:</label>