Browse Source

fixed moe

Josh Kamau 5 years ago
parent
commit
40e3f9e20a

+ 3 - 1
app/Http/Controllers/PatientController.php

@@ -3,13 +3,15 @@
 namespace App\Http\Controllers;
 
 use App\Models\Client;
+use App\Models\Pro;
 use Illuminate\Http\Request;
 
 class PatientController extends Controller
 {
     public function dashboard(Request $request, Client $patient )
     {
-        return view('app.patient.dashboard', compact('patient'));
+        $pros = Pro::where('is_enrolled_as_mcp', true)->get();
+        return view('app.patient.dashboard', compact('patient','pros'));
     }
 
     public function carePlan(Request $request, Client $patient )

+ 10 - 0
app/Models/Client.php

@@ -2,6 +2,8 @@
 
 namespace App\Models;
 
+use Illuminate\Database\Eloquent\Relations\HasOne;
+
 # use Illuminate\Database\Eloquent\Model;
 
 class Client extends Model
@@ -12,4 +14,12 @@ class Client extends Model
         return $this->name_last . ', '. $this->name_first;
     }
 
+    public function mcp(){
+        return $this->hasOne(Pro::class, 'id', 'mcp_pro_id');
+    }
+
+    public function cm(){
+        return $this->hasOne(Pro::class, 'id', 'cm_pro_id');
+    }
+
 }

+ 3 - 0
public/css/yemi.css

@@ -0,0 +1,3 @@
+[moe] [url]:not([show]){
+    display: none;
+}

+ 990 - 0
public/js/yemi.js

@@ -0,0 +1,990 @@
+if (typeof focusOn == 'undefined') {
+    var focusOn = 'globalSearch';
+}
+
+var ajaxGoing = false;
+
+var showMask = function () {
+    $('body').css('opacity', 0.6);
+    $('#mask').show();
+}
+
+var hideMask = function () {
+    $('body').css('opacity', 1);
+    $('#mask').hide();
+}
+
+$(document).ready(function () {
+    hideMask();
+});
+
+$(document).ready(function () {
+    $("input[type=number]").keydown(function (e) {
+        // Allow: backspace, delete, tab, escape, enter and .
+        if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||
+            // Allow: Ctrl+A, Command+A
+            (e.keyCode == 65 && (e.ctrlKey === true || e.metaKey === true)) ||
+            // Allow: home, end, left, right, down, up
+            (e.keyCode >= 35 && e.keyCode <= 40)) {
+            // let it happen, don't do anything
+            return;
+        }
+        // Ensure that it is a number and stop the keypress
+        if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
+            e.preventDefault();
+        }
+    });
+});
+
+$(function () {
+    $('input[type=checkbox][forceCb]').on('click', function () {
+        var name = $(this).attr('forceCb');
+        var code = $(this).attr('code');
+        var form = $(this).closest('form');
+        var hiddenField = $(form).find('input[code=\'' + code + '\']');
+        var value = $(this).prop('checked') ? 'on' : 'off';
+        console.log('name', name, 'code', code, 'value', value);
+        $(hiddenField).val(value);
+    });
+});
+
+var doAjax = function (url, data, pre, post, onSuccess, onFailure, suppressErrorMessage, onHttpFailure, shouldHideMask, immediatelyHideMaskOnReply) {
+    console.log(data);
+    if (ajaxGoing) {
+        console.log('ajax stopped!');
+        //return; TODO: fix and re-enable return
+    }
+    ajaxGoing = true;
+    if (!shouldHideMask) {
+        showMask();
+    }
+    jQuery.ajax(url, {
+            dataType: 'json',
+            data: data,
+            type: 'POST',
+            beforeSend: function () {
+                if (pre) {
+                    pre();
+                }
+            }
+        })
+        .done(function (response, b) {
+			console.log(response);
+            var success = response.success;
+            if (success) {
+                if (onSuccess) {
+                    onSuccess(response.data);
+                }
+            } else {
+                if (onFailure) {
+                    onFailure(response.message);
+                }
+                if (!suppressErrorMessage) {
+                    //toast the error message
+                    alert(response.message);
+                }
+                hideMask();
+            }
+            if (immediatelyHideMaskOnReply) {
+                hideMask();
+            }
+            ajaxGoing = false;
+        })
+        .fail(function (jqXHR, textStatus) {
+            if (onHttpFailure) {
+                onHttpFailure(textStatus);
+            }
+            ajaxGoing = false;
+        })
+        .always(function () {
+            if (post) {
+                post();
+            }
+            ajaxGoing = false;
+        });
+};
+
+var justLog = false; //THIS IS FOR TEST MODE, FORMS WILL NOT TRIGGER REFRESH/REDIR
+
+var pageReload = function () {
+    setTimeout(function () {
+        window.location.reload(true);
+    }, 500);
+};
+
+if (typeof String.prototype.startsWith != 'function') {
+    // see below for better implementation!
+    String.prototype.startsWith = function (str) {
+        return this.indexOf(str) === 0;
+    };
+}
+
+$(function () {
+    $('[addressLine1]').each(function () {
+        var moe = $(this).closest('[moe]');
+        var a = {};
+        a.addressLine1 = $(this);
+        a.addressLine2 = $(moe).find('[addressLine2]');
+        a.addressCity = $(moe).find('[addressCity]');
+        a.addressState = $(moe).find('[addressState]');
+        a.addressPostcode = $(moe).find('[addressPostcode]');
+        var getAddress = function () {
+            var address = {};
+            for (var prop in a) {
+                var val = $(a[prop]).val();
+                address[prop] = val;
+            }
+            return address;
+        }
+        var getFormattedAddress = function (address) {
+            var x = '<p>';
+            x += address.addressLine1 + (address.addressLine2 ? ', ' + address.addressLine2 : '') + '<br/>' + address.addressCity + ', ' + address.addressState + ' ' + address.addressPostcode;
+            x += '</p>';
+            return x;
+        }
+        var suggestAddress = function () {
+            var address = getAddress();
+            //var doAjax = function (url, data, pre, post, onSuccess, onFailure, suppressErrorMessage, onHttpFailure, shouldHideMask)
+            var onSuccess = function (data) {
+                console.log('SUCCESS!!!', data);
+            }
+            var onFailure = function (message) {
+                if (message.startsWith('Invalid:: INVALID ADDRESS - SUGGESTED:')) {
+                    var suggestionText = message.substring(message.indexOf('{'));
+                    var suggestion = JSON.parse(suggestionText);
+                    console.log('SUGGESTION!!!', suggestion);
+                    $('#myModal').attr('title', 'Address suggestion');
+                    $('#myModal').html('<h3>Currently set address:</h3>' + getFormattedAddress(address) + '<h3>Suggestion:</h3>' + getFormattedAddress(suggestion));
+                    $('#myModal').dialog({
+                        height: 400,
+                        width: 500,
+                        modal: true,
+                        buttons: [{
+                                text: 'Use suggestion',
+                                click: function () {
+                                    for (var prop in a) {
+                                        $(a[prop]).val(suggestion[prop]);
+                                    }
+                                    $(this).dialog('close');
+                                }
+                            },
+                            {
+                                text: 'Keep original',
+                                click: function () {
+                                    $(this).dialog('close');
+                                }
+                            }
+                        ]
+                    });
+                } else if (message.startsWith('Invalid:: INVALID ADDRESS')) {
+                    console.log('NO SUGGESTION!!!');
+                    $('#myModal').attr('title', 'No address found');
+                    $('#myModal').html('<h3>Currently set address:</h3>' + getFormattedAddress(address) + '<h3>No suggestion!</h3>');
+                    $('#myModal').dialog({
+                        height: 400,
+                        width: 500,
+                        modal: true,
+                        buttons: [{
+                                text: 'Erase address fields',
+                                click: function () {
+                                    for (var prop in a) {
+                                        $(a[prop]).val('');
+                                    }
+                                    $(this).dialog('close');
+                                }
+                            },
+                            {
+                                text: 'Keep original',
+                                click: function () {
+                                    $(this).dialog('close');
+                                }
+                            }
+                        ]
+                    });
+                }
+            }
+            doAjax('/api/service/verifyAddress', address, null, null, onSuccess, onFailure, true, null, false, true);
+        }
+        var isAddressComplete = function () {
+            var address = getAddress();
+            return address.addressLine1 && ((address.addressCity && address.addressState) || address.addressPostcode) ? true : false;
+        }
+        for (var prop in a) {
+            var part = a[prop];
+            $(part).on('change', function () {
+                console.log(getAddress());
+                var isComplete = isAddressComplete();
+                if (isComplete) {
+                    suggestAddress();
+                }
+            });
+            $(part).attr('autocomplete', 'off');
+        }
+    });
+});
+
+jQuery(document).ready(function () {
+    var $ = jQuery;
+
+    $('[moe]').each(function () {
+        var moe = $(this);
+        moe.isProcessing = false;
+        var info = moe.find('[info]')[0]; // OPTIONAL
+        var start = moe.find('[start]')[0]; // OPTIONAL
+        var form = moe.find('[url]')[0]; // REQUIRED
+        var url = $(form).attr('url'); // REQUIRED
+        var redir = $(form).attr('redir'); // OPTIONAL
+        var submit = moe.find('[submit]'); // REQUIRED
+        var cancel = moe.find('[cancel]')[0]; // OPTIONAL
+
+
+        if ($(this).attr('formOff') != null) {
+            $(form).find(':input').attr('disabled', true);
+            var formOn = $(this).find('[formOn]');
+            $(formOn).attr('disabled', false);
+            $(submit).hide();
+            $(formOn).click(function () {
+                $(form).find(':input').attr('disabled', false);
+                $(submit).show();
+                $(formOn).hide();
+                return false;
+            });
+        }
+
+        var realForm = form;
+
+        //init set display inline so toggle remembers inline state
+        var formToggle = false;
+        var infoToggle = false;
+
+        if (start) {
+            $(start).click(function () {
+                if ($(realForm).attr('show') == null) {
+                    if (!formToggle && $(realForm).attr('liner') != null) {
+                        $(realForm).css('display', 'inline');
+                        formToggle = true;
+                    } else {
+                        $(realForm).toggle(100);
+                    }
+                }
+                if (!infoToggle && info && $(info).attr('show') == null) {
+                    if ($(info).attr('liner') != null) {
+                        $(info).css('display', 'inline');
+                        infoToggle = true;
+                    } else {
+                        $(info).toggle(100);
+                    }
+                }
+                if ($(start).attr('show') == null) {
+                    $(start).toggle(100);
+                }
+                var focusOnStart = $(realForm).find('[focusOnStart]');
+                if (focusOnStart) {
+                    $(focusOnStart).focus();
+                }
+                return false;
+            });
+            $(start).attr('href', '#');
+        }
+        if (cancel) {
+            $(cancel).click(function (e) {
+                e.preventDefault();
+                e.stopImmediatePropagation();
+                if ($(realForm).attr('show') == null) {
+                    $(realForm).hide(100);
+                }
+                if (info && $(info).attr('show') == null) {
+                    $(info).show(100);
+                }
+                if (start && $(start).attr('show') == null) {
+                    $(start).show(100);
+                }
+            });
+        }
+        $(submit).click(function (e) {
+            e.preventDefault();
+            e.stopImmediatePropagation();
+            if (moe.isProcessing) {
+                return false;
+            }
+            if ($(submit).attr('confirm')) {
+                var question = $(submit).attr('confirm');
+                var cont = confirm(question);
+                if (cont) {} else {
+                    console.log("ABORTED!");
+                    return;
+                }
+            }
+            moe.isProcessing = true;
+            var data = {};
+            var formData = $(form).serializeArray();
+            formData.forEach(function (field) {
+                if (data[field.name]) {
+                    if (data[field.name] instanceof Array) {
+                        data[field.name].push(field.value);
+                    } else {
+                        var arr = [];
+                        arr.push(data[field.name]);
+                        arr.push(field.value);
+                        data[field.name] = arr;
+                    }
+                } else {
+                    data[field.name] = field.value;
+                }
+            });
+            console.log(data);
+            doAjax(url, data, null, function () {
+                moe.isProcessing = false;
+            }, function (data) {
+                if (justLog) { // this is to test!
+                    console.log('RETURNED', data);
+                } else if (redir) {
+                    if (redir == "back") {
+                        window.history.back();
+                    } else {
+                        var host = window.location.host;
+                        if (redir.indexOf('[uid]') > -1) {
+							redir = redir.replace('[uid]', data)
+                            window.location.href = '/' + redir;
+                        } else {
+                            window.location.href = '/' + redir;
+                        }
+                    }
+                } else {
+                    pageReload();
+                }
+            });
+        });
+    });
+
+    $('table[info] input').each(function () {
+        $(this).prop('readonly', true);
+    });
+
+    //...for checkboxes readonly
+    $('input[type=checkbox][readonly],input[type=radio][readonly]').each(function () {
+        var x = this;
+        var isChecked = $(x).attr('checked');
+        $(x).change(function () {
+            $(x).attr('checked', isChecked);
+        });
+    });
+
+    $('[show-if]').each(function () { //TODO show-if="isOpen"    show-if="isTimeSpecific"    show-if="refillFrequency=MONTH"
+        var x = this;
+        var sel = $(x).attr('show-if');
+        var selParts = sel.split('=');
+        var selName = selParts[0];
+        var selValue = selParts[1];
+        var useOpposite = selName[0] == '!';
+        if (useOpposite) {
+            selName = selName.slice(1);
+        }
+        var form = $(x).closest('form');
+        var conditionFields = $(form).find('[name=' + selName + ']');
+
+        function hideX() {
+            $(x).hide();
+        }
+
+        function showX() {
+            $(x).show();
+        }
+        var go = function () {
+            if (selValue) {
+                var value = $(conditionFields).val();
+                if (value == selValue) {
+                    if (useOpposite) {
+                        hideX()
+                    } else {
+                        showX()
+                    }
+                } else {
+                    if (useOpposite) {
+                        showX()
+                    } else {
+                        hideX()
+                    }
+                }
+            } else {
+                var isChecked = $(conditionFields).prop('checked');
+                if (isChecked) {
+                    if (useOpposite) {
+                        hideX()
+                    } else {
+                        showX()
+                    }
+                } else {
+                    if (useOpposite) {
+                        showX()
+                    } else {
+                        hideX()
+                    }
+                }
+            }
+        };
+        go();
+        $(conditionFields).change(function () {
+            go();
+        });
+    });
+
+});
+
+//now goTo is a plugin...
+(function ($) {
+    $.fn.goTo = function (x) {
+        $('html, body').animate({
+            scrollTop: ($(this).offset().top - x) + 'px'
+        }, 1);
+        return this; // for chaining...
+    };
+})(jQuery);
+
+$(document).ready(function () {
+    $(".expander").on("click", function () {
+        var expandedID = $(this).attr("id");
+        if ($(this).text() == "-") {
+            $(this).text("+");
+        } else {
+            $(this).text("-");
+        }
+        $("." + expandedID).toggle();
+        return false;
+    });
+});
+
+
+
+$(document).ready(function () {
+    $('[showMap]').each(function () {
+        var mapper = $(this);
+        var adr = mapper.attr('showMap');
+        mapper.on('click', function () {
+            showAddr(adr);
+            return false;
+        });
+    });
+});
+
+
+$(document).ready(function () {
+    $('[dateRanger]').each(function () {
+        var dr = $(this);
+        var rangeTypeSelect = dr.find('select')[0];
+        var date1Input = dr.find('[date1]')[0];
+        var date2Input = dr.find('[date2]')[0];
+        var d1Val = '';
+        var d2Val = '';
+        var d1 = function (enable) {
+            if (enable) {
+                var hasVal = $(date1Input).val();
+                if (!hasVal) {
+                    $(date1Input).val(d1Val);
+                }
+                $(date1Input).show();
+            } else {
+                d1Val = $(date1Input).val();
+                $(date1Input).val('');
+                $(date1Input).hide();
+            }
+        };
+        var d2 = function (enable) {
+            if (enable) {
+                var hasVal = $(date2Input).val();
+                if (!hasVal) {
+                    $(date2Input).val(d2Val);
+                }
+                $(date2Input).show();
+            } else {
+                d2Val = $(date2Input).val();
+                $(date2Input).val('');
+                $(date2Input).hide();
+            }
+        };
+        var adjustFields = function () {
+            var rangeType = $(rangeTypeSelect).val();
+            if (rangeType == 'all') {
+                d1();
+                d2();
+            } else if (rangeType == 'on-or-before') {
+                d1(true);
+                d2();
+            } else if (rangeType == 'on-or-after') {
+                d1(true);
+                d2();
+            } else if (rangeType == 'between') {
+                d1(true);
+                d2(true);
+            } else if (rangeType == 'on') {
+                d1(true);
+                d2();
+            } else if (rangeType == 'not-on') {
+                d1(true);
+                d2();
+            } else if (rangeType == 'not-in-between') {
+                d1(true);
+                d2(true);
+            }
+        };
+        adjustFields();
+        $(rangeTypeSelect).change(function () {
+            adjustFields();
+        });
+    });
+    $('[numRanger]').each(function () {
+        var nr = $(this);
+        var rangeTypeSelect = nr.find('select')[0];
+        var num1Input = nr.find('[num1]')[0];
+        var num2Input = nr.find('[num2]')[0];
+        var n1 = function (enable) {
+            if (enable) {
+                $(num1Input).show();
+            } else {
+                $(num1Input).hide();
+            }
+        };
+        var n2 = function (enable) {
+            if (enable) {
+                $(num2Input).show();
+            } else {
+                $(num2Input).hide();
+            }
+        };
+        var adjustFields = function () {
+            var rangeType = $(rangeTypeSelect).val();
+            if (rangeType == 'all') {
+                n1();
+                n2();
+            } else if (rangeType == 'less-than') {
+                n1(true);
+                n2();
+            } else if (rangeType == 'greater-than') {
+                n1(true);
+                n2();
+            } else if (rangeType == 'equal-to') {
+                n1(true);
+                n2();
+            } else if (rangeType == 'between') {
+                n1(true);
+                n2(true);
+            } else if (rangeType == 'not-equal-to') {
+                n1(true);
+                n2();
+            } else if (rangeType == 'not-in-between') {
+                n1(true);
+                n2(true);
+            }
+        };
+        adjustFields('all');
+        $(rangeTypeSelect).change(function () {
+            adjustFields();
+        });
+    });
+});
+$(document).ready(function () {
+    $('[minzero]').on('change', function () {
+        var val = $(this).val();
+        val = parseFloat(val);
+        if (val < 0) {
+            alert('This number cannot be less than zero.');
+            $(this).val('');
+            $(this).focus();
+        }
+    });
+});
+
+var showAddr = function (adr) {
+    window.open('http://192.241.155.210/geo.php?adr=' + adr, new Date().getTime(), "height=400,width=520");
+};
+
+$(document).ready(function () {
+    var globalSearch = function () {
+        var substring = $('#globalSearch').val();
+        console.log("SUBSTRING", substring);
+        if (substring.length > 2) {
+            $("#results").show();
+            $("#results").load("/global-search?substring=" + encodeURIComponent(substring));
+        } else {
+            $("#results").hide();
+        }
+    };
+    $("#globalSearch").on('keyup', function (evnt) {
+        globalSearch();
+    });
+    $("#globalSearch").on('focus', function (evnt) {
+        globalSearch();
+    });
+    $("#globalSearch").on('blur', function (evt) {
+        setTimeout(function () {
+            $("#results").hide();
+        }, 500);
+    });
+});
+
+$('a[aller]').attr('href', '#');
+var selectAll = true;
+$('a[aller]').click(function () {
+    $('input[type=checkbox][aller]').each(function () {
+        if (!$(this).is(':disabled')) {
+            $(this).prop('checked', selectAll);
+        }
+    });
+    selectAll = !selectAll;
+    return false;
+});
+
+$('button[batcher]').click(function () {
+    var url = $(this).attr('batcher');
+    var rid = $(this).attr('rid');
+    batcher(url, rid);
+    return false;
+});
+
+var batcherGoing = false;
+
+var batcher = function (url, recordIdName) {
+    if (batcherGoing) {
+        return;
+    }
+    batcherGoing = true;
+    var jobs = [];
+    $('input[type=checkbox][job]').each(function () {
+        if (this.checked) {
+            jobs.push(this);
+        }
+    });
+    console.log('JOBS', jobs);
+    var pointer = 0;
+    var doJob = function () {
+        var job = jobs[pointer];
+        if (job) {
+            pointer++;
+            var recordID = $(job).attr('job');
+            var data = {
+                isBatch: true
+            };
+            data[recordIdName] = recordID;
+            doAjax(url, data,
+                function () {
+                    var messageCell = $(job).closest('td')[0];
+                    if (messageCell) {
+                        $(messageCell).find('.errorMessage').remove();
+                    }
+                    $(job).closest('tr').css('background', 'gray');
+                },
+                function () {
+                    doJob();
+                },
+                function (res) {
+                    $(job).closest('tr').css('background', '#83D3C1');
+                    $(job).prop('checked', false);
+                    $(job).prop('disabled', true);
+                    var messageCell = $(job).closest('td')[0];
+                    if (messageCell) {
+                        $(messageCell).find('.errorMessage').remove();
+                        $(messageCell).append('<span class="errorMessage">success!</span>');
+                    }
+                },
+                function (mess) {
+                    var tr = $(job).closest('tr');
+                    $(tr).css('background', '#ED4337');
+                    var messageCell = $(job).closest('td')[0];
+                    if (messageCell) {
+                        $(messageCell).find('.errorMessage').remove();
+                        $(messageCell).append('<span class="errorMessage"> ' + mess + '</span>');
+                    }
+                    var shouldContinue = confirm('Error processing record ID: ' + recordID + '\n\nMessage: ' + mess + '\n\nContinue?');
+                    if (shouldContinue) {
+                        //carry on...
+                    } else {
+                        jobs = [];
+                    }
+                }, true);
+        } else {
+            batcherGoing = false;
+        }
+    }
+    doJob();
+}
+
+
+$(function () {
+
+    $('.showOnLoad').show();
+
+});
+
+$(function () {
+    var i = 0;
+
+    function pulsate() {
+        $(".urgentIndicator").
+        animate({
+            opacity: 0.2
+        }, 200, 'linear').
+        animate({
+            opacity: 1
+        }, 200, 'linear', pulsate);
+    }
+    pulsate();
+});
+
+$(function () {
+    $('[remote-searcher]').each(function () {
+
+        var me = this;
+
+        $(me).hide();
+
+        var selections = [];
+
+        var isMulti = typeof $(me).attr('multiple') == 'string';
+
+        $(me).find('[rid]').each(function () {
+            selections.push({
+                id: $(this).attr('rid'),
+                display: $(this).attr('display')
+            });
+        });
+
+        if (!isMulti && selections[0]) {
+            selections = [selections[0]];
+        }
+
+        $(me).html('');
+
+        var url = $(me).attr('remote-searcher');
+        var charMin = $(me).attr('char-min');
+        var name = $(me).attr('name');
+
+        $(me).append('<select multiple style="display:none;" name="' + name + '"></select><span choices></span><input type="text" style="border:none;margin:5px;width:100%;outline:none;display:none;"/></span>');
+        $(me).append('<div style="margin-top:2px;background:white;border:1px lightgray solid;display:none;width:99%;position:absolute;z-index:999"></div>');
+
+        var choices = $(me).find('span[choices]');
+
+        var selectField = $(me).find('select');
+        var textField = $(me).find('input[type=text]');
+        var resultDiv = $(me).find('div');
+
+        var setResultMask = function () {
+            $(resultDiv).html('<div style="background-image: url(/icons/vanillaspin.gif); background-repeat: no-repeat; width:100%; height:60px;background-position: center;"></div>');
+        }
+
+        var fillSelected = function (selected) {
+            $(selectField).html('');
+            $(choices).html('');
+            selected.forEach(function (choice, index) {
+                if (isMulti || (!isMulti && index == 0)) {
+                    $(selectField).append('<option selected value="' + choice.id + '">' + choice.display + '</option>');
+                    $(choices).append('<button style="margin:2px;" rid="' + choice.id + '" index="' + index + '">' + choice.display + ' x</button>');
+                }
+            });
+            $(choices).find('button').on('click', function () {
+                var btn = this;
+                var rid = $(btn).attr('rid');
+                var index = $(btn).attr('index');
+                selections.splice(index, 1);
+                fillSelected(selected);
+                return false;
+            });
+        }
+
+        fillSelected(selections);
+
+        var setValue = function (val, display) {
+            if (!isMulti) {
+                selections = [];
+            }
+            // get rid of earliers
+            for (var i = 0; i < selections.length; i++) {
+                var sel = selections[i];
+                if (sel.id == parseInt(val)) {
+                    selections.splice(i, 1);
+                }
+            }
+            selections.push({
+                id: val,
+                display: display
+            });
+            fillSelected(selections);
+            $(textField).val('');
+            $(textField).hide();
+        }
+
+        var getMatches = function () {
+            var substring = $(textField).val();
+            if (charMin > substring.length) {
+                return;
+            }
+            setResultMask();
+            $(resultDiv).show();
+            //url, data, pre, post, onSuccess, onFailure, suppressErrorMessage, onHttpFailure, shouldHideMask
+            doAjax(url, {
+                substring: substring
+            }, null, null, function (matches) {
+                $(resultDiv).find('[rid]').each(function () {
+                    $(this).off()
+                });
+                $(resultDiv).html('');
+                matches.forEach(function (match) {
+                    if (typeof match == 'string') {
+                        match = {
+                            id: match,
+                            display: match
+                        }
+                    }
+                    if (typeof match == 'object' && !match.id) {
+                        match.id = match.display;
+                    }
+                    $(resultDiv).append('<a href="#" class="searcher-result" display="' + match.display + '" rid="' + match.id + '">' + match.display + '</a>');
+                });
+                $(resultDiv).find('[rid]').each(function () {
+                    var result = this;
+                    $(result).mousedown('click', function () {
+                        var val = $(result).attr('rid');
+                        var display = $(result).attr('display');
+                        setValue(val, display);
+                        //$(textField).hide();
+                        return false;
+                    });
+                });
+            }, null, true, null, true);
+        };
+
+        $(textField).on('keyup', function () {
+            getMatches();
+        });
+
+        $(textField).on('blur', function () {
+            $(textField).val('');
+            $(textField).hide();
+            if ($(resultDiv).is(':visible')) {
+                $(resultDiv).hide();
+            };
+        });
+
+        $(textField).on('focus', function () {
+            getMatches();
+        });
+
+        $(me).on('click', function () {
+            $(textField).show();
+            $(textField).focus();
+        });
+
+        $(me).show();
+    });
+});
+
+$(document).ready(function () {
+    $('[bulk-batcher]').on('click', function () {
+        var url = $(this).attr('url');
+        var ridname = $(this).attr('rid');
+        var ids = [];
+        var target = $(this).attr('target');
+        $('[job]:checked').each(function () {
+            ids.push($(this).attr('job'));
+        });
+        console.log(ids);
+        var data = {};
+        data[ridname] = JSON.stringify(ids);
+        console.log(data);
+        doAjax(url, data, null, null, function (batchID) {
+            if (target) {
+                window.open('/' + target + batchID, new Date().getTime(), "height=500,width=500");
+            } else {
+                window.location.href = '/batch-process?id=' + batchID;
+            }
+        }, null, false, null, true);
+    });
+});
+
+$(document).ready(function () {
+    // setInterval(function () {
+    //     doAjax('/api/session/test', null, null, null, null, function () {
+    //         window.location.reload(true);
+    //     }, true, null, true);
+    // }, 10000);
+});
+
+$(document).ready(function () {
+    if (focusOn) {
+        $('#' + focusOn).focus();
+    }
+});
+
+$(function () {
+    $('[setMaskOnClick]').click(function () {
+        showMask();
+    });
+});
+
+$(function () {
+    $('[point=percentCalc]').each(function () {
+        var pc = this;
+        var calculateTotalAmount = function () {
+            var table = $(pc).closest('table');
+            var total = 0;
+            $(table).find('[point=itemPercent]').each(function () {
+                var ip = this;
+                var percent = $(ip).val();
+                var amount = $(ip).attr('amount');
+                var itemTotal = 0;
+                if (percent) {
+                    itemTotal = (amount * percent * .01);
+                }
+                itemTotal = parseFloat(itemTotal);
+                total += itemTotal;
+                $(ip).closest('tr').find('[point=itemAmount]').html('$' + itemTotal.toFixed(2));
+            });
+            T = total;
+            $(table).find('[point=mainAmount]').html('$' + total.toFixed(2));
+        }
+        $(pc).closest('table').find('[point=applyAll]').click(function () {
+            var val = $(this).closest('td').find('[point=itemPercent]').val();
+            var table = $(this).closest('table');
+            $(table).find('[point=itemPercent]').val(val);
+            calculateTotalAmount();
+        });
+        $(pc).find('[point=itemPercent]').change(function () {
+            calculateTotalAmount();
+        });
+    });
+});
+
+
+$(function () {
+    $('input[type=file][ajaxload]').each(function () {
+        var me = this;
+        var name = $(me).attr('ajaxload');
+        $(me).wrap('<span class="ajaxload"></span>');
+        $(me).closest('span').append('<input type="hidden" name="' + name + '"/>');
+        $(me).on('change', function (event) {
+            console.log("file received.");
+            var fileField = me;
+            var files = event.target.files;
+            var data = new FormData();
+            $.each(files, function (key, value) {
+                data.append(key, value);
+            });
+            $.ajax({
+                url: '/api/systemFile/upload',
+                type: 'POST',
+                data: data,
+                cache: false,
+                dataType: 'json',
+                processData: false, // Don't process the files
+                contentType: false, // Set content type to false as jQuery will tell the server its a query string request
+                success: function (data, textStatus, jqXHR) {
+                    var systemFileID = data.data;
+                    console.log("UPLOAD WORKED::", data);
+                    $(me).closest('span').find('input[type=hidden]').val(systemFileID);
+                },
+                error: function (jqXHR, textStatus, errorThrown) {
+                    console.log('ERRORS: ' + textStatus);
+                }
+            });
+        });
+    });
+});

+ 1 - 1
resources/views/app/new-patient.blade.php

@@ -13,7 +13,7 @@
             </strong>
         </div>
         <div class="card-body">
-            <form show url="/api/client/create" class="px-3 pt-3 pb-1" redir="patients/view/">
+            <form show url="/api/client/create" class="px-3 pt-3 pb-1" redir="patients/view/[uid]">
                 @csrf
 
                 @if (session('message'))

+ 44 - 5
resources/views/layouts/patient.blade.php

@@ -94,25 +94,64 @@
                                     <div class="pl-3">
                                         <strong>PCP:</strong>
                                         @if($patient->mcp)
-                                            {{$patient->mcp->displayName()}}...
+                                            {{$patient->mcp->name_display}}...
                                             @if($patient->has_mcp_done_onboarding_visit == 'YES')
                                                 <strong>First E&M Visit:</strong> {{$patient->mcp_onboarding_visit_date}}...
                                                 <strong>Last E&M Visit:</strong>{$patient->most_recent_mcp_em_visit_date}...
                                                 <strong>Next E&M Visit:</strong> {$patient->next_mcp_em_visit_date}
                                             @else
-                                                Patient has not been seen yet!
+                                                <div class="alert alert-success text-sm p-1">
+                                                    <i class="fa fa-exclamation-circle" aria-hidden="true"></i>
+                                                    Patient has not been seen yet!
+                                                </div>
                                             @endif
                                         @else
-                                            none! [assign someone]
+                                            none! 
+                                            <div moe>
+                                                <a href="" start show>[assign someone]</a>
+                                                <form url="/api/client/putMcp">
+                                                    <input type="hidden" name="uid" value="{{$patient->uid}}">
+                                                    <div class="form-group">
+                                                        <select name="mcpProUid"  class="form-control">
+                                                            <option value="">-- select mcp --</option>
+                                                            @foreach ($pros as $pro)
+                                                            <option value="{{$pro->uid}}">{{$pro->name_display}}</option>
+                                                            @endforeach
+                                                        </select>
+                                                    </div>
+                                                    <div class="form-group">
+                                                        <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                        <button class="btn btn-secondary btn-sm" cancel>Cancel</button>
+                                                    </div>
+                                                </form>
+                                            </div>
                                         @endif
                                     </div>
                                     <div class="d-flex">
                                         <div class="pl-3">
                                             <strong>MA:</strong>
                                             @if($patient->cm)
-                                                {{$patient->cm->displayName()}}
+                                                {{$patient->cm->name_display}}
                                             @else
-                                                none! [assign someone]
+                                                none! 
+                                                <div moe>
+                                                    <a href="" start show>[assign someone]</a>
+                                                    <form url="/api/client/putCmPro">
+                                                        <input type="hidden" name="uid" value="{{$patient->uid}}">
+                                                        <div class="form-group">
+                                                            <select name="cmProUid"  class="form-control">
+                                                                <option value="">-- select cm --</option>
+                                                                @foreach ($pros as $pro)
+                                                                <option value="{{$pro->uid}}">{{$pro->name_display}}</option>
+                                                                @endforeach
+                                                            </select>
+                                                        </div>
+                                                        <div class="form-group">
+                                                            <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                            <button class="btn btn-secondary btn-sm" cancel>Cancel</button>
+                                                        </div>
+                                                    </form>
+                                                </div>
                                             @endif
                                         </div>
                                     </div>

+ 2 - 1
resources/views/layouts/template.blade.php

@@ -14,11 +14,12 @@
     <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.1/css/all.min.css">
     <link href="{{ asset('/css/app.css') }}" rel="stylesheet">
     <link href="{{ asset('/css/style.css') }}" rel="stylesheet">
+    <link href="{{ asset('/css/yemi.css') }}" rel="stylesheet">
     <!-- Styles -->
 
     <script src="{{ asset('js/app.js') }}" type="application/javascript"></script>
     <script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
-    <script src="{{ asset('js/yemi.min.js') }}" type="application/javascript"></script>
+    <script src="{{ asset('js/yemi.js') }}" type="application/javascript"></script>
 
     @yield('head')
 </head>