Просмотр исходного кода

Merge branch 'master' of rav.triplestart.com:jmudaka/stagfe2

= 4 лет назад
Родитель
Сommit
f58ce9b875

+ 3 - 3
app/Http/Controllers/Controller.php

@@ -48,10 +48,10 @@ class Controller extends BaseController
         }*/
 
         view()->share('pros',$this->pros);
-        view()->share('notes', Note::all());
+        // view()->share('notes', Note::all());
 
-        $noteTemplates = NoteTemplate::all();
-        view()->share('noteTemplates', $noteTemplates);
+        // $noteTemplates = NoteTemplate::all();
+        // view()->share('noteTemplates', $noteTemplates);
 
         $initiatives = ['LHI', 'BHI'];
         view()->share('intiatives', $initiatives);

+ 43 - 1
app/Http/Controllers/HomeController.php

@@ -304,7 +304,49 @@ class HomeController extends Controller
 
         $milliseconds = strtotime(date('Y-m-d')) . '000';
 
-        $measurements = $performer->pro->getMeasurements();
+        // $measurements = $performer->pro->getMeasurements();
+
+        $myClientIDs = [];
+        if ($performer->pro->pro_type != 'ADMIN') {
+            $myClientIDs = $this->getMyClientIds();
+        }
+
+        $measurements = DB::select(
+            DB::raw(
+"
+SELECT measurement.uid as uid,
+       care_month.uid as care_month_uid,
+       measurement.label,
+       measurement.value,
+       measurement.sbp_mm_hg,
+       measurement.dbp_mm_hg,
+       measurement.numeric_value,
+       measurement.ts,
+       client.uid as client_uid,
+       client.name_last,
+       client.name_first,
+       care_month.rm_total_time_in_seconds
+FROM measurement
+         join client on measurement.client_id = client.id
+         join care_month on client.id = care_month.client_id
+WHERE measurement.label NOT IN ('SBP', 'DBP')
+  AND (measurement.is_cellular_zero = FALSE or measurement.is_cellular_zero IS NULL)
+  AND measurement.is_removed IS FALSE
+  AND measurement.ts IS NOT NULL
+  AND measurement.client_bdt_measurement_id IS NOT NULL
+  AND (measurement.status IS NULL OR (measurement.status <> 'ACK' AND measurement.status <> 'INVALID_ACK'))
+  AND EXTRACT(MONTH from care_month.start_date) = EXTRACT(MONTH from now())
+  AND EXTRACT(YEAR from care_month.start_date) = EXTRACT(YEAR from now())
+" .
+                (
+                    $performer->pro->pro_type != 'ADMIN' && count($myClientIDs) ?
+                        ' AND WHERE client.id IN (' . implode(", ", $myClientIDs) . ')' :
+                        ''
+                )
+            ) .
+" ORDER BY measurement.ts DESC LIMIT 12"
+
+        );
 
         // bills & claims
         $businessNumbers = [];

+ 20 - 4
app/Http/Controllers/NoteController.php

@@ -3,6 +3,7 @@
 namespace App\Http\Controllers;
 
 use App\Models\Pro;
+use App\Models\SupplyOrder;
 use App\Models\Ticket;
 use Illuminate\Http\Request;
 use Illuminate\Support\Collection;
@@ -35,20 +36,35 @@ class NoteController extends Controller
         $allyPros = Pro::all(); //TODO: paginate, use select2
 
         // load tickets created on note->effective_date for patient
-        $ticketsOnNoteEffectiveDate = Ticket::where('client_id', $patient->id)
+        $ticketsOnNote = Ticket::where('client_id', $patient->id)
             ->where('is_entry_error', false)
-            ->whereRaw('DATE(created_at) = DATE(?)', [$note->effective_dateest])
+            ->where('note_id', $note->id)
             ->get();
 
         // other open tickets as of today
         $otherOpenTickets = Ticket::where('client_id', $patient->id)
             ->where('is_entry_error', false)
             ->where('is_open', true)
-            ->whereRaw('DATE(created_at) <> DATE(?)', [$note->effective_dateest])
+            ->where(function ($query) use ($note) {
+                $query->where('note_id', '<>', $note->id)->orWhereNull('note_id'); // weird, but just the <> isn't working!
+            })
+            ->get();
+
+        // load supplyOrders created on note->effective_date for patient
+        $supplyOrdersOnNote = SupplyOrder::where('client_id', $patient->id)
+            ->where('is_cancelled', false)
+            ->where('note_id', $note->id)
+            ->get();
+
+        // other open supplyOrders as of today
+        $otherOpenSupplyOrders = SupplyOrder::where('client_id', $patient->id)
+            ->where('is_cancelled', false)
             ->get();
 
         return view('app.patient.note.dashboard', compact('patient', 'note',
-            'allyPros', 'allSections', 'ticketsOnNoteEffectiveDate', 'otherOpenTickets'));
+            'allyPros', 'allSections',
+            'ticketsOnNote', 'otherOpenTickets',
+            'supplyOrdersOnNote', 'otherOpenSupplyOrders'));
     }
 
     public function renderNote($noteUid, Request $request)

+ 32 - 16
app/Http/Controllers/PatientController.php

@@ -21,6 +21,7 @@ use App\Models\Shipment;
 use App\Models\SupplyOrder;
 use App\Models\Ticket;
 use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\File;
 
 class PatientController extends Controller
@@ -47,14 +48,22 @@ class PatientController extends Controller
     {
         $mcpPros = Pro::where('is_enrolled_as_mcp', true)->get();
         $facilities = []; // Facility::where('is_active', true)->get();
-        $devices = BDTDevice::where('is_active', true)->orderBy('imei', 'asc')->get();
-        $devices = $devices->filter(function ($record) {
-            $matching = ClientBDTDevice
-                ::where('device_id', $record->id)
-                ->where('is_active', true)
-                ->get();
-            return count($matching) === 0;
-        });
+
+        // get assigned devices
+        $assignedDeviceIDs = DB::select(DB::raw("SELECT device_id from client_bdt_device where is_active = true"));
+        $assignedDeviceIDs = array_map(function($_x) {
+            return $_x->device_id;
+        }, $assignedDeviceIDs);
+
+        // get all except assigned ones
+        $devices = BDTDevice::where('is_active', true)
+            ->whereNotIn('id', $assignedDeviceIDs)
+            ->orderBy('imei', 'asc')
+            ->get();
+
+        $assignedDeviceIDs = null;
+        unset($assignedDeviceIDs);
+
         $dxInfoLines = ClientInfoLine::where('client_id', $patient->id)
             ->where('category', 'dx')
             ->where('is_removed', false)
@@ -177,14 +186,21 @@ class PatientController extends Controller
 
     public function devices(Request $request, Client $patient )
     {
-        $devices = BDTDevice::where('is_active', true)->get();
-        $devices = $devices->filter(function ($record) {
-            $matching = ClientBDTDevice
-                ::where('device_id', $record->id)
-                ->where('is_active', true)
-                ->get();
-            return count($matching) === 0;
-        });
+        // get assigned devices
+        $assignedDeviceIDs = DB::select(DB::raw("SELECT device_id from client_bdt_device where is_active = true"));
+        $assignedDeviceIDs = array_map(function($_x) {
+            return $_x->device_id;
+        }, $assignedDeviceIDs);
+
+        // get all except assigned ones
+        $devices = BDTDevice::where('is_active', true)
+            ->whereNotIn('id', $assignedDeviceIDs)
+            ->orderBy('imei', 'asc')
+            ->get();
+
+        $assignedDeviceIDs = null;
+        unset($assignedDeviceIDs);
+
         return view('app.patient.devices', compact('patient', 'devices'));
     }
 

+ 1 - 0
composer.json

@@ -21,6 +21,7 @@
         "soundasleep/html2text": "^1.1"
     },
     "require-dev": {
+        "barryvdh/laravel-debugbar": "^3.5",
         "facade/ignition": "^2.0",
         "fzaninotto/faker": "^1.9.1",
         "mockery/mockery": "^1.3.1",

+ 209 - 3
composer.lock

@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "e7cde7c8677189cd07a9aa7de4f54c20",
+    "content-hash": "d01222da17fb9fe201059a9f90767292",
     "packages": [
         {
             "name": "asm89/stack-cors",
@@ -4222,6 +4222,83 @@
         }
     ],
     "packages-dev": [
+        {
+            "name": "barryvdh/laravel-debugbar",
+            "version": "v3.5.2",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/barryvdh/laravel-debugbar.git",
+                "reference": "cae0a8d1cb89b0f0522f65e60465e16d738e069b"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/cae0a8d1cb89b0f0522f65e60465e16d738e069b",
+                "reference": "cae0a8d1cb89b0f0522f65e60465e16d738e069b",
+                "shasum": ""
+            },
+            "require": {
+                "illuminate/routing": "^6|^7|^8",
+                "illuminate/session": "^6|^7|^8",
+                "illuminate/support": "^6|^7|^8",
+                "maximebf/debugbar": "^1.16.3",
+                "php": ">=7.2",
+                "symfony/debug": "^4.3|^5",
+                "symfony/finder": "^4.3|^5"
+            },
+            "require-dev": {
+                "mockery/mockery": "^1.3.3",
+                "orchestra/testbench-dusk": "^4|^5|^6",
+                "phpunit/phpunit": "^8.5|^9.0",
+                "squizlabs/php_codesniffer": "^3.5"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "3.5-dev"
+                },
+                "laravel": {
+                    "providers": [
+                        "Barryvdh\\Debugbar\\ServiceProvider"
+                    ],
+                    "aliases": {
+                        "Debugbar": "Barryvdh\\Debugbar\\Facade"
+                    }
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Barryvdh\\Debugbar\\": "src/"
+                },
+                "files": [
+                    "src/helpers.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Barry vd. Heuvel",
+                    "email": "barryvdh@gmail.com"
+                }
+            ],
+            "description": "PHP Debugbar integration for Laravel",
+            "keywords": [
+                "debug",
+                "debugbar",
+                "laravel",
+                "profiler",
+                "webprofiler"
+            ],
+            "funding": [
+                {
+                    "url": "https://github.com/barryvdh",
+                    "type": "github"
+                }
+            ],
+            "time": "2021-01-06T14:21:44+00:00"
+        },
         {
             "name": "doctrine/instantiator",
             "version": "1.3.1",
@@ -4556,6 +4633,7 @@
                 "faker",
                 "fixtures"
             ],
+            "abandoned": true,
             "time": "2019-12-12T13:22:17+00:00"
         },
         {
@@ -4606,6 +4684,67 @@
             ],
             "time": "2016-01-20T08:20:44+00:00"
         },
+        {
+            "name": "maximebf/debugbar",
+            "version": "v1.16.5",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/maximebf/php-debugbar.git",
+                "reference": "6d51ee9e94cff14412783785e79a4e7ef97b9d62"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/6d51ee9e94cff14412783785e79a4e7ef97b9d62",
+                "reference": "6d51ee9e94cff14412783785e79a4e7ef97b9d62",
+                "shasum": ""
+            },
+            "require": {
+                "php": "^7.1|^8",
+                "psr/log": "^1.0",
+                "symfony/var-dumper": "^2.6|^3|^4|^5"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^7.5.20 || ^9.4.2"
+            },
+            "suggest": {
+                "kriswallsmith/assetic": "The best way to manage assets",
+                "monolog/monolog": "Log using Monolog",
+                "predis/predis": "Redis storage"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.16-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "DebugBar\\": "src/DebugBar/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Maxime Bouroumeau-Fuseau",
+                    "email": "maxime.bouroumeau@gmail.com",
+                    "homepage": "http://maximebf.com"
+                },
+                {
+                    "name": "Barry vd. Heuvel",
+                    "email": "barryvdh@gmail.com"
+                }
+            ],
+            "description": "Debug bar in the browser for php application",
+            "homepage": "https://github.com/maximebf/php-debugbar",
+            "keywords": [
+                "debug",
+                "debugbar"
+            ],
+            "time": "2020-12-07T11:07:24+00:00"
+        },
         {
             "name": "mockery/mockery",
             "version": "1.4.0",
@@ -5355,6 +5494,7 @@
             "keywords": [
                 "tokenizer"
             ],
+            "abandoned": true,
             "time": "2019-09-17T06:23:10+00:00"
         },
         {
@@ -6124,6 +6264,72 @@
             "homepage": "https://github.com/sebastianbergmann/version",
             "time": "2016-10-03T07:35:21+00:00"
         },
+        {
+            "name": "symfony/debug",
+            "version": "v4.4.20",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/debug.git",
+                "reference": "157bbec4fd773bae53c5483c50951a5530a2cc16"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/symfony/debug/zipball/157bbec4fd773bae53c5483c50951a5530a2cc16",
+                "reference": "157bbec4fd773bae53c5483c50951a5530a2cc16",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=7.1.3",
+                "psr/log": "~1.0",
+                "symfony/polyfill-php80": "^1.15"
+            },
+            "conflict": {
+                "symfony/http-kernel": "<3.4"
+            },
+            "require-dev": {
+                "symfony/http-kernel": "^3.4|^4.0|^5.0"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Symfony\\Component\\Debug\\": ""
+                },
+                "exclude-from-classmap": [
+                    "/Tests/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Fabien Potencier",
+                    "email": "fabien@symfony.com"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "https://symfony.com/contributors"
+                }
+            ],
+            "description": "Provides tools to ease debugging PHP code",
+            "homepage": "https://symfony.com",
+            "funding": [
+                {
+                    "url": "https://symfony.com/sponsor",
+                    "type": "custom"
+                },
+                {
+                    "url": "https://github.com/fabpot",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2021-01-28T16:54:48+00:00"
+        },
         {
             "name": "theseer/tokenizer",
             "version": "1.1.3",
@@ -6169,12 +6375,12 @@
             "version": "1.9.0",
             "source": {
                 "type": "git",
-                "url": "https://github.com/webmozart/assert.git",
+                "url": "https://github.com/webmozarts/assert.git",
                 "reference": "9dc4f203e36f2b486149058bade43c851dd97451"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/webmozart/assert/zipball/9dc4f203e36f2b486149058bade43c851dd97451",
+                "url": "https://api.github.com/repos/webmozarts/assert/zipball/9dc4f203e36f2b486149058bade43c851dd97451",
                 "reference": "9dc4f203e36f2b486149058bade43c851dd97451",
                 "shasum": ""
             },

+ 2 - 0
config/app.php

@@ -181,6 +181,7 @@ return [
         App\Providers\RouteServiceProvider::class,
 
         Barryvdh\DomPDF\ServiceProvider::class,
+        Barryvdh\Debugbar\ServiceProvider::class,
     ],
 
     /*
@@ -234,6 +235,7 @@ return [
         'View' => Illuminate\Support\Facades\View::class,
 
         'PDF' => Barryvdh\DomPDF\Facade::class,
+        'Debugbar' => Barryvdh\Debugbar\Facade::class,
 
     ],
 

+ 218 - 0
config/debugbar.php

@@ -0,0 +1,218 @@
+<?php
+
+return [
+
+    /*
+     |--------------------------------------------------------------------------
+     | Debugbar Settings
+     |--------------------------------------------------------------------------
+     |
+     | Debugbar is enabled by default, when debug is set to true in app.php.
+     | You can override the value by setting enable to true or false instead of null.
+     |
+     | You can provide an array of URI's that must be ignored (eg. 'api/*')
+     |
+     */
+
+    'enabled' => env('DEBUGBAR_ENABLED', null),
+    'except' => [
+        'telescope*',
+        'horizon*',
+    ],
+
+    /*
+     |--------------------------------------------------------------------------
+     | Storage settings
+     |--------------------------------------------------------------------------
+     |
+     | DebugBar stores data for session/ajax requests.
+     | You can disable this, so the debugbar stores data in headers/session,
+     | but this can cause problems with large data collectors.
+     | By default, file storage (in the storage folder) is used. Redis and PDO
+     | can also be used. For PDO, run the package migrations first.
+     |
+     */
+    'storage' => [
+        'enabled'    => true,
+        'driver'     => 'file', // redis, file, pdo, socket, custom
+        'path'       => storage_path('debugbar'), // For file driver
+        'connection' => null,   // Leave null for default connection (Redis/PDO)
+        'provider'   => '', // Instance of StorageInterface for custom driver
+        'hostname'   => '127.0.0.1', // Hostname to use with the "socket" driver
+        'port'       => 2304, // Port to use with the "socket" driver
+    ],
+
+    /*
+     |--------------------------------------------------------------------------
+     | Vendors
+     |--------------------------------------------------------------------------
+     |
+     | Vendor files are included by default, but can be set to false.
+     | This can also be set to 'js' or 'css', to only include javascript or css vendor files.
+     | Vendor files are for css: font-awesome (including fonts) and highlight.js (css files)
+     | and for js: jquery and and highlight.js
+     | So if you want syntax highlighting, set it to true.
+     | jQuery is set to not conflict with existing jQuery scripts.
+     |
+     */
+
+    'include_vendors' => true,
+
+    /*
+     |--------------------------------------------------------------------------
+     | Capture Ajax Requests
+     |--------------------------------------------------------------------------
+     |
+     | The Debugbar can capture Ajax requests and display them. If you don't want this (ie. because of errors),
+     | you can use this option to disable sending the data through the headers.
+     |
+     | Optionally, you can also send ServerTiming headers on ajax requests for the Chrome DevTools.
+     */
+
+    'capture_ajax' => true,
+    'add_ajax_timing' => false,
+
+    /*
+     |--------------------------------------------------------------------------
+     | Custom Error Handler for Deprecated warnings
+     |--------------------------------------------------------------------------
+     |
+     | When enabled, the Debugbar shows deprecated warnings for Symfony components
+     | in the Messages tab.
+     |
+     */
+    'error_handler' => false,
+
+    /*
+     |--------------------------------------------------------------------------
+     | Clockwork integration
+     |--------------------------------------------------------------------------
+     |
+     | The Debugbar can emulate the Clockwork headers, so you can use the Chrome
+     | Extension, without the server-side code. It uses Debugbar collectors instead.
+     |
+     */
+    'clockwork' => false,
+
+    /*
+     |--------------------------------------------------------------------------
+     | DataCollectors
+     |--------------------------------------------------------------------------
+     |
+     | Enable/disable DataCollectors
+     |
+     */
+
+    'collectors' => [
+        'phpinfo'         => true,  // Php version
+        'messages'        => true,  // Messages
+        'time'            => true,  // Time Datalogger
+        'memory'          => true,  // Memory usage
+        'exceptions'      => true,  // Exception displayer
+        'log'             => true,  // Logs from Monolog (merged in messages if enabled)
+        'db'              => true,  // Show database (PDO) queries and bindings
+        'views'           => true,  // Views with their data
+        'route'           => true,  // Current route information
+        'auth'            => false, // Display Laravel authentication status
+        'gate'            => true,  // Display Laravel Gate checks
+        'session'         => true,  // Display session data
+        'symfony_request' => true,  // Only one can be enabled..
+        'mail'            => true,  // Catch mail messages
+        'laravel'         => false, // Laravel version and environment
+        'events'          => false, // All events fired
+        'default_request' => false, // Regular or special Symfony request logger
+        'logs'            => false, // Add the latest log messages
+        'files'           => false, // Show the included files
+        'config'          => false, // Display config settings
+        'cache'           => false, // Display cache events
+        'models'          => true,  // Display models
+        'livewire'        => true,  // Display Livewire (when available)
+    ],
+
+    /*
+     |--------------------------------------------------------------------------
+     | Extra options
+     |--------------------------------------------------------------------------
+     |
+     | Configure some DataCollectors
+     |
+     */
+
+    'options' => [
+        'auth' => [
+            'show_name' => true,   // Also show the users name/email in the debugbar
+        ],
+        'db' => [
+            'with_params'       => true,   // Render SQL with the parameters substituted
+            'backtrace'         => true,   // Use a backtrace to find the origin of the query in your files.
+            'backtrace_exclude_paths' => [],   // Paths to exclude from backtrace. (in addition to defaults)
+            'timeline'          => false,  // Add the queries to the timeline
+            'explain' => [                 // Show EXPLAIN output on queries
+                'enabled' => false,
+                'types' => ['SELECT'],     // Deprecated setting, is always only SELECT
+            ],
+            'hints'             => false,    // Show hints for common mistakes
+            'show_copy'         => false,    // Show copy button next to the query
+        ],
+        'mail' => [
+            'full_log' => false,
+        ],
+        'views' => [
+            'data' => false,    //Note: Can slow down the application, because the data can be quite large..
+        ],
+        'route' => [
+            'label' => true,  // show complete route on bar
+        ],
+        'logs' => [
+            'file' => null,
+        ],
+        'cache' => [
+            'values' => true, // collect cache values
+        ],
+    ],
+
+    /*
+     |--------------------------------------------------------------------------
+     | Inject Debugbar in Response
+     |--------------------------------------------------------------------------
+     |
+     | Usually, the debugbar is added just before </body>, by listening to the
+     | Response after the App is done. If you disable this, you have to add them
+     | in your template yourself. See http://phpdebugbar.com/docs/rendering.html
+     |
+     */
+
+    'inject' => true,
+
+    /*
+     |--------------------------------------------------------------------------
+     | DebugBar route prefix
+     |--------------------------------------------------------------------------
+     |
+     | Sometimes you want to set route prefix to be used by DebugBar to load
+     | its resources from. Usually the need comes from misconfigured web server or
+     | from trying to overcome bugs like this: http://trac.nginx.org/nginx/ticket/97
+     |
+     */
+    'route_prefix' => '_debugbar',
+
+    /*
+     |--------------------------------------------------------------------------
+     | DebugBar route domain
+     |--------------------------------------------------------------------------
+     |
+     | By default DebugBar route served from the same domain that request served.
+     | To override default domain, specify it as a non-empty value.
+     */
+    'route_domain' => null,
+
+    /*
+     |--------------------------------------------------------------------------
+     | DebugBar theme
+     |--------------------------------------------------------------------------
+     |
+     | Switches between light and dark theme. If set to auto it will respect system preferences
+     | Possible values: auto, light, dark
+     */
+    'theme' => 'auto',
+];

+ 6 - 0
public/js/stag-popup.js

@@ -3,6 +3,12 @@ function showStagPopup(_key, _noAutoFocus) {
     /*$('html, body').addClass('no-scroll');
     $(window.top.document.body).find('#stag_mcp_lhs').addClass('no-scroll');*/
     let stagPopup = $('[stag-popup-key="' + _key + '"]');
+    if(stagPopup.is('.show')) return false;
+    else {
+        let zIndex = $('.stag-popup.show[stag-popup-key]').last().css('z-index');
+        if(zIndex) zIndex++; else zIndex = 100;
+        stagPopup.css('z-index', zIndex);
+    }
     stagPopup.addClass('show');
     stagPopup.find('[moe][initialized]').removeAttr('initialized');
     initMoes();

+ 137 - 0
resources/views/app/dashboard/measurements-eloquent.blade.php

@@ -0,0 +1,137 @@
+<div class="d-flex align-items-end mb-3">
+    <b class="large">Measurements in {{friendly_month(date('Y-m-d'))}}</b>
+</div>
+<table class="table table-striped table-sm table-bordered mb-0">
+    <thead>
+        <tr>
+            <th class="border-0 px-2 text-secondary">Patient</th>
+            <th class="border-0 px-2 text-secondary">Category</th>
+            <th class="border-0 px-2 text-secondary">Value</th>
+            <th class="border-0 px-2 text-secondary">Timestamp</th>
+            <th class="border-0 px-2 text-secondary">Mins this month</th>
+            <th class="border-0 px-2 text-secondary text-center">Stamp</th>
+            <th class="border-0 px-2 text-secondary text-center">Entry</th>
+        </tr>
+    </thead>
+    <tbody>
+        @if(count($measurements))
+            <?php foreach($measurements as $measurement): ?>
+                <?php if(in_array($measurement->label, ['SBP', 'DBP']) ) continue; ?>
+                <tr>
+                    <td class="px-2">
+                        <a href="/patients/view/{{$measurement->client->uid}}" class="font-weight-bold">
+                            {{ $measurement->client->name_first }} {{ $measurement->client->name_last }}
+                        </a>
+                    </td>
+                    <td class="px-2">{{ $measurement->label }}</td>
+                    <td class="px-2">
+                        @if($measurement->is_cellular_zero)
+                            <i class="font-size-11 fa fa-rss"></i>
+                        @elseif($measurement->label === 'BP')
+                            {{ $measurement->sbp_mm_hg }}/{{ $measurement->dbp_mm_hg }} mmHg
+                        @elseif($measurement->label === 'Wt. (lbs.)')
+                            {{ round(floatval($measurement->numeric_value), 2) }} lbs
+                        @else
+                            {{ $measurement->value }}
+                        @endif
+                    </td>
+                    <td>
+                        {{ friendly_date_time_short_with_tz_from_timestamp_divide1000($measurement->ts, 'EASTERN') }}
+                        EST
+                    </td>
+                    <td class="px-2">
+                        @if($measurement->careMonth)
+                        {{ floor($measurement->careMonth->rm_total_time_in_seconds/60) }}
+                        @endif
+                    </td>
+                    <td colspan="px-2">
+                        @if($measurement->clientBdtMeasurement)
+                        <span moe large relative>
+                            <a start show class="py-0 mb-3 font-weight-bold">Update status</a>
+                            <form url="/api/measurement/updateStatus" right>
+                                <input type="hidden" name="uid" value="{{$measurement->uid}}">
+                                <select name="status" id="" class="form-control input-sm">
+                                    <option value="">--select--</option>
+                                    <option value="ACK">Ok</option>
+                                    <option value="INVALID_ACK">Invalid</option>
+                                </select>
+                                <div class="d-flex align-items-center mt-2">
+                                    <button class="btn btn-sm btn-success mr-2" submit>Submit</button>
+                                    <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
+                                </div>
+                            </form>
+                        </span>
+                        <div v-else class="text-center">-</div>
+                        @endif
+                    </td>
+                    <td colspan="px-2">
+                        @if($measurement->clientBdtMeasurement)
+                        <div class="text-center">
+                            <span moe large relative>
+                                <a start show class="py-0 mb-3 font-weight-bold">Add</a>
+                                <form url="/api/careMonthEntry/createForRm" right>
+                                    <p class="mb-2 d-block text-left"><b>Add RM Entry</b></p>
+                                    <input type="hidden" name="careMonthUid" value="{{$measurement->careMonth->uid}}">
+                                    <input type="hidden" name="proUid" value="{{$pro->uid}}">
+                                    <input type="hidden" name="effectiveDate" value="{{date('Y-m-d')}}">
+                                    <div class="bg-light border rounded p-2 mb-2">
+                                        <div class="mb-1 d-flex align-items-center">
+                                            <span class="width-50px text-left text-secondary">Type</span>
+                                            <div><b>{{ $measurement->label }} </b></div>
+                                        </div>
+                                        <div class="d-flex align-items-center">
+                                            <span class="width-50px text-left text-secondary">Value</span>
+                                            @if(!$measurement->clientBDTMeasurement)
+                                                <div><b>{{ $measurement->value }}</b></div>
+                                            @else
+                                                <div>
+                                                    @if($measurement->label == 'BP')
+                                                    <div>
+                                                        <b>{{ $measurement->clientBdtMeasurement->measurement->systolic_bp_in_mm_hg }}</b>/<b>{{ $measurement->clientBdtMeasurement->measurement->diastolic_bp_in_mm_hg }}</b> mmHg
+                                                    </div>
+                                                    @endif
+                                                    @if($measurement->label == 'Wt. (lbs.)')
+                                                    <div>
+                                                        <b>{{ floor($measurement->clientBdtMeasurement->measurement->weight_in_pounds)}}</b> lbs
+                                                    </div>
+                                                    @endif
+                                                </div>
+                                            @endif
+                                        </div>
+                                    </div>
+                                    <div class="mb-2">
+                                        <div class="row">
+                                            <div class="col-6 d-flex align-items-center">
+                                                <label class="text-secondary text-sm my-0 mr-3 text-nowrap">Time (mins)</label>
+                                                <input type="number" min="0" max="5400" class="form-control form-control-sm w-100 cm-time-value" name="timeInMinutes" value="" placeholder="Time (mins.)" required>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="mb-2">
+                                        <div class="row">
+                                            <div class="col-12 text-left">
+                                                <label class="text-secondary text-sm mb-1">Details</label>
+                                                <textarea class="form-control form-control-sm" rows="4" name="contentText">{{ 'Reviewed ' . $measurement->label . ' measurement' }}</textarea>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="d-flex align-items-center">
+                                        <button class="btn btn-sm btn-success mr-2" submit>Submit</button>
+                                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
+                                    </div>
+                                </form>
+                            </span>
+                        </div>
+                        @endif
+                    </td>
+                </tr>
+            <?php endforeach ?>
+        @else
+            <tr>
+                <td class="text-secondary p-0 p-3" colspan="7">
+                    No items to show
+                </td>
+            </tr>
+        @endif
+    </tbody>
+</table>

+ 18 - 28
resources/views/app/dashboard/measurements.blade.php

@@ -16,18 +16,15 @@
     <tbody>
         @if(count($measurements))
             <?php foreach($measurements as $measurement): ?>
-                <?php if(in_array($measurement->label, ['SBP', 'DBP']) ) continue; ?>
                 <tr>
                     <td class="px-2">
-                        <a href="/patients/view/{{$measurement->client->uid}}" class="font-weight-bold">
-                            {{ $measurement->client->name_first }} {{ $measurement->client->name_last }}
+                        <a href="/patients/view/{{$measurement->client_uid}}" class="font-weight-bold">
+                            {{ $measurement->name_first }} {{ $measurement->name_last }}
                         </a>
                     </td>
                     <td class="px-2">{{ $measurement->label }}</td>
                     <td class="px-2">
-                        @if($measurement->is_cellular_zero)
-                            <i class="font-size-11 fa fa-rss"></i>
-                        @elseif($measurement->label === 'BP')
+                        @if($measurement->label === 'BP')
                             {{ $measurement->sbp_mm_hg }}/{{ $measurement->dbp_mm_hg }} mmHg
                         @elseif($measurement->label === 'Wt. (lbs.)')
                             {{ round(floatval($measurement->numeric_value), 2) }} lbs
@@ -40,12 +37,13 @@
                         EST
                     </td>
                     <td class="px-2">
-                        @if($measurement->careMonth)
-                        {{ floor($measurement->careMonth->rm_total_time_in_seconds/60) }}
+                        @if($measurement->rm_total_time_in_seconds)
+                            {{ floor($measurement->rm_total_time_in_seconds/60) }}
+                        @else
+                            0
                         @endif
                     </td>
                     <td colspan="px-2">
-                        @if($measurement->clientBdtMeasurement)
                         <span moe large relative>
                             <a start show class="py-0 mb-3 font-weight-bold">Update status</a>
                             <form url="/api/measurement/updateStatus" right>
@@ -61,17 +59,14 @@
                                 </div>
                             </form>
                         </span>
-                        <div v-else class="text-center">-</div>
-                        @endif
                     </td>
                     <td colspan="px-2">
-                        @if($measurement->clientBdtMeasurement)
                         <div class="text-center">
                             <span moe large relative>
                                 <a start show class="py-0 mb-3 font-weight-bold">Add</a>
                                 <form url="/api/careMonthEntry/createForRm" right>
                                     <p class="mb-2 d-block text-left"><b>Add RM Entry</b></p>
-                                    <input type="hidden" name="careMonthUid" value="{{$measurement->careMonth->uid}}">
+                                    <input type="hidden" name="careMonthUid" value="{{$measurement->care_month_uid}}">
                                     <input type="hidden" name="proUid" value="{{$pro->uid}}">
                                     <input type="hidden" name="effectiveDate" value="{{date('Y-m-d')}}">
                                     <div class="bg-light border rounded p-2 mb-2">
@@ -81,22 +76,18 @@
                                         </div>
                                         <div class="d-flex align-items-center">
                                             <span class="width-50px text-left text-secondary">Value</span>
-                                            @if(!$measurement->clientBDTMeasurement)
-                                                <div><b>{{ $measurement->value }}</b></div>
-                                            @else
+                                            <div>
+                                                @if($measurement->label == 'BP')
+                                                <div>
+                                                    <b>{{ $measurement->sbp_mm_hg }}/{{ $measurement->dbp_mm_hg }} mmHg</b>
+                                                </div>
+                                                @endif
+                                                @if($measurement->label == 'Wt. (lbs.)')
                                                 <div>
-                                                    @if($measurement->label == 'BP')
-                                                    <div>
-                                                        <b>{{ $measurement->clientBdtMeasurement->measurement->systolic_bp_in_mm_hg }}</b>/<b>{{ $measurement->clientBdtMeasurement->measurement->diastolic_bp_in_mm_hg }}</b> mmHg
-                                                    </div>
-                                                    @endif
-                                                    @if($measurement->label == 'Wt. (lbs.)')
-                                                    <div>
-                                                        <b>{{ floor($measurement->clientBdtMeasurement->measurement->weight_in_pounds)}}</b> lbs
-                                                    </div>
-                                                    @endif
+                                                    <b>{{ round(floatval($measurement->numeric_value), 2) }}</b> lbs
                                                 </div>
-                                            @endif
+                                                @endif
+                                            </div>
                                         </div>
                                     </div>
                                     <div class="mb-2">
@@ -122,7 +113,6 @@
                                 </form>
                             </span>
                         </div>
-                        @endif
                     </td>
                 </tr>
             <?php endforeach ?>

+ 1 - 0
resources/views/app/patient/care-month/dashboard.blade.php

@@ -60,6 +60,7 @@
                                             class="form-control form-control-sm if-visit-done"
                                             onchange="toggleVisibilityAsNeeded(this, '', 'if-note-outside-system')">
                                         <option value="">-- Visit Note --</option>
+                                        <?php $notes = \App\Models\Note::where('client_id', $patient->id)->get() ?>
                                         @foreach ($notes as $note)
                                             @if(!empty($note->title) && $note->client_id === $patient->id && !$note->is_cancelled)
                                                 <option value="{{$note->uid}}">{{$note->title}}</option>

+ 8 - 7
resources/views/app/patient/dashboard.blade.php

@@ -69,12 +69,13 @@
                 @endif
 
                 {{-- devices --}}
-                <?php $availableDevices = 0; ?>
-                @foreach($devices as $device)
-                    @if(!$patient->hasDevice($device))
-                        <?php $availableDevices++; ?>
-                    @endif
-                @endforeach
+                <?php
+                $availableDevices = count($devices);
+                $patientDeviceIDs = \App\Models\ClientBDTDevice::select('id')->where('client_id', $patient->id)->where('is_active', true)->get()->toArray();
+                $patientDeviceIDs = array_map(function($_x) {
+                    return $_x["id"];
+                }, $patientDeviceIDs);
+                ?>
                 <div class="mt-2 pb-1" id="patient-dashboard-devices">
                     <div class="d-flex align-items-center mb-2 py-2 border-top border-bottom">
                         <h6 class="my-0 font-weight-bold text-secondary">Devices</h6>
@@ -89,7 +90,7 @@
                                     <select name="deviceUid" class="form-control form-control-sm">
                                         <option value=""> --select-- </option>
                                         @foreach($devices as $device)
-                                            @if(!$patient->hasDevice($device))
+                                            @if(!in_array($device->id, $patientDeviceIDs))
                                             <option value="{{$device->uid}}">
                                                 {{$device->imei}} ({{$device->category}})
                                             </option>

+ 313 - 199
resources/views/app/patient/note/dashboard.blade.php

@@ -377,153 +377,28 @@
                                class="ticket-popup-trigger note-dashboard-action d-block text-nowrap">
                                 + Imaging
                             </a>
-                            <span class="mx-2 text-secondary">|</span>
-                            <a native target="_blank"
-                               open-in-stag-popup
-                               update-parent
-                               mc-initer="patient-supply-orders"
-                               title="{{$patient->displayName()}} - Supply Orders"
-                               href="/patients/view/{{$patient->uid}}/supply-orders?popupmode=1&note-uid={{$note->uid}}&filter=active">
-                                Supply Orders
-                            </a>
                         </div>
 
-                        <hr class="my-2">
+                        <div class="p-3 border">
 
-                        <p class="font-weight-bold text-secondary mb-2 mr-2">Ordered on {{friendlier_date($note->effective_dateest)}} <span class="font-weight-normal">(note's effective date)</span></p>
-                        <div>
-                            @if($ticketsOnNoteEffectiveDate && count($ticketsOnNoteEffectiveDate))
-                                <table class="table table-sm table-bordered mb-0">
-                                <thead>
-                                <tr class="bg-light">
-                                    <th class="px-2 text-secondary border-bottom-0 width-30px">Created</th>
-                                    <th class="px-2 text-secondary border-bottom-0 width-30px">Type</th>
-                                    <th class="px-2 text-secondary border-bottom-0 width-30px">Pro</th>
-                                    <th class="px-2 text-secondary border-bottom-0 width-30px">View</th>
-                                    <th class="px-2 text-secondary border-bottom-0 width-30px">Status</th>
-                                    <th class="px-2 text-secondary border-bottom-0">Detail</th>
-                                </tr>
-                                </thead>
-                                <tbody>
-                                @foreach($ticketsOnNoteEffectiveDate as $ticket)
-                                    <?php $data = json_decode($ticket->data); ?>
-                                    @if($ticket->category === 'erx' || $ticket->category === 'lab' || $ticket->category === 'imaging')
-                                    <tr class="{{$ticket->is_open ? '' : 'bg-light on-hover-opaque'}}">
-                                        <td class="px-2 text-nowrap">
-                                            {{friendly_time($ticket->created_at)}}
-                                        </td>
-                                        <td class="px-2 text-nowrap">
-                                            {{$ticket->category}}
-                                        </td>
-                                        <td class="px-2 text-nowrap">
-                                            @if($ticket->orderingPro)
-                                                @if($ticket->orderingPro->id !== $pro->id)
-                                                    <b>{{$ticket->orderingPro->displayName()}}</b>
-                                                @else
-                                                    You
-                                                @endif
-                                            @else
-                                                -
-                                            @endif
-                                        </td>
-                                        <td class="px-2 text-nowrap">
-                                            <div class="d-flex align-items-center flex-nowrap">
-                                                <a href="/patients/view/{{$ticket->patient->uid}}/tickets/{{$ticket->category}}/{{$ticket->uid}}?popupmode=1"
-                                                   native target="_blank"
-                                                   class="ticket-popup-trigger note-dashboard-action d-block text-nowrap mr-3">
-                                                    View
-                                                </a>
-                                            </div>
-                                        </td>
-                                        <td class="px-2 text-nowrap">
-                                            {{$ticket->is_open ? 'Open' : 'Closed'}}
-                                        </td>
-                                        <td class="px-2">
-                                        @if($ticket->category === 'erx')
-                                            <div class="font-size-13 mb-1">{{$data->medication}}</div>
-                                            <div class="d-flex align-items-center flex-wrap text-secondary">
-                                                @if($data->strength)
-                                                    <span class="d-inline-flex align-items-center">
-                                                        <span class="mx-2 text-secondary">•</span>
-                                                        <span>{{$data->strength}}</span>
-                                                    </span>
-                                                @endif
-                                                @if($data->route)
-                                                    <span class="d-inline-flex align-items-center">
-                                                        <span class="mx-2 text-secondary">•</span>
-                                                        <span>{{$data->route}}</span>
-                                                    </span>
-                                                @endif
-                                                @if($data->frequency)
-                                                    <span class="d-inline-flex align-items-center">
-                                                        <span class="mx-2 text-secondary">•</span>
-                                                        <span>{{$data->frequency}}</span>
-                                                    </span>
-                                                @endif
-                                                @if($data->dispense)
-                                                    <span class="d-inline-flex align-items-center">
-                                                        <span class="mx-2 text-secondary">•</span>
-                                                        <span>Dispense:</span> {{$data->dispense}}
-                                                    </span>
-                                                @endif
-                                                @if($data->frequency)
-                                                    <span class="d-inline-flex align-items-center">
-                                                        <span class="mx-2 text-secondary">•</span>
-                                                        <span><span>Refills:</span> {{$data->refills}}</span>
-                                                    </span>
-                                                @endif
-                                                @if($data->dispense)
-                                                    <span class="d-inline-flex align-items-center">
-                                                        <span class="mx-2 text-secondary">•</span>
-                                                        <span><span>Purpose:</span> {{$data->purpose}}</span>
-                                                    </span>
-                                                @endif
-                                            </div>
-                                        @endif
-                                        @if($ticket->category === 'lab' || $ticket->category === 'imaging')
-                                            @if(@$data->tests && is_array($data->tests))
-                                                <div>
-                                                    <span class="text-secondary">Tests:</span>
-                                                    {{implode(", ", $data->tests)}}
-                                                </div>
-                                            @endif
-                                            @if(@$data->icds && is_array($data->icds))
-                                                <div>
-                                                    <span class="text-secondary">ICDs:</span>
-                                                    {{implode(", ", $data->icds)}}
-                                                </div>
-                                            @endif
-                                        @endif
-                                        </td>
+                            <p class="font-weight-bold text-secondary mb-2 mr-2">Associated with this note</p>
+                            <div>
+                                @if($ticketsOnNote && count($ticketsOnNote))
+                                    <table class="table table-sm table-bordered mb-0">
+                                    <thead>
+                                    <tr class="bg-light">
+                                        <th class="px-2 text-secondary border-bottom-0 width-30px">Created</th>
+                                        <th class="px-2 text-secondary border-bottom-0 width-30px">Type</th>
+                                        <th class="px-2 text-secondary border-bottom-0 width-30px">Pro</th>
+                                        <th class="px-2 text-secondary border-bottom-0 width-30px">View</th>
+                                        <th class="px-2 text-secondary border-bottom-0 width-30px">Status</th>
+                                        <th class="px-2 text-secondary border-bottom-0">Detail</th>
                                     </tr>
-                                    @endif
-                                @endforeach
-                                </tbody>
-                                </table>
-                            @else
-                                <div class="text-secondary">None</div>
-                            @endif
-                        </div>
-
-                        <hr class="my-2">
-
-                        <p class="font-weight-bold text-secondary mb-2 mr-2 mt-3">Others open as of {{friendlier_date(date('Y-m-d'))}}</p>
-                        @if($otherOpenTickets && count($otherOpenTickets))
-                            <table class="table table-sm table-bordered mb-0">
-                                <thead>
-                                <tr class="bg-light">
-                                    <th class="px-2 text-secondary border-bottom-0 width-30px">Created</th>
-                                    <th class="px-2 text-secondary border-bottom-0 width-30px">Type</th>
-                                    <th class="px-2 text-secondary border-bottom-0 width-30px">Pro</th>
-                                    <th class="px-2 text-secondary border-bottom-0 width-30px">View</th>
-                                    <th class="px-2 text-secondary border-bottom-0 width-30px">Status</th>
-                                    <th class="px-2 text-secondary border-bottom-0">Detail</th>
-                                </tr>
-                                </thead>
-                                <tbody>
-                                @foreach($otherOpenTickets as $ticket)
-                                    <?php $data = json_decode($ticket->data); ?>
-                                    @if($ticket->category === 'erx' || $ticket->category === 'lab' || $ticket->category === 'imaging')
+                                    </thead>
+                                    <tbody>
+                                    @foreach($ticketsOnNote as $ticket)
+                                        <?php $data = json_decode($ticket->data); ?>
+                                        @if($ticket->category === 'erx' || $ticket->category === 'lab' || $ticket->category === 'imaging')
                                         <tr class="{{$ticket->is_open ? '' : 'bg-light on-hover-opaque'}}">
                                             <td class="px-2 text-nowrap">
                                                 {{friendly_time($ticket->created_at)}}
@@ -555,70 +430,309 @@
                                                 {{$ticket->is_open ? 'Open' : 'Closed'}}
                                             </td>
                                             <td class="px-2">
-                                                @if($ticket->category === 'erx')
-                                                    <div class="font-size-13 mb-1">{{$data->medication}}</div>
-                                                    <div class="d-flex align-items-center flex-wrap text-secondary">
-                                                        @if($data->strength)
-                                                            <span class="d-inline-flex align-items-center">
-                                                    <span class="mx-2 text-secondary">•</span>
-                                                    <span>{{$data->strength}}</span>
-                                                </span>
-                                                        @endif
-                                                        @if($data->route)
-                                                            <span class="d-inline-flex align-items-center">
-                                                    <span class="mx-2 text-secondary">•</span>
-                                                    <span>{{$data->route}}</span>
-                                                </span>
-                                                        @endif
-                                                        @if($data->frequency)
-                                                            <span class="d-inline-flex align-items-center">
-                                                    <span class="mx-2 text-secondary">•</span>
-                                                    <span>{{$data->frequency}}</span>
-                                                </span>
-                                                        @endif
-                                                        @if($data->dispense)
-                                                            <span class="d-inline-flex align-items-center">
-                                                    <span class="mx-2 text-secondary">•</span>
-                                                    <span>Dispense:</span> {{$data->dispense}}
-                                                </span>
-                                                        @endif
-                                                        @if($data->frequency)
-                                                            <span class="d-inline-flex align-items-center">
-                                                    <span class="mx-2 text-secondary">•</span>
-                                                    <span><span>Refills:</span> {{$data->refills}}</span>
-                                                </span>
-                                                        @endif
-                                                        @if($data->dispense)
-                                                            <span class="d-inline-flex align-items-center">
-                                                    <span class="mx-2 text-secondary">•</span>
-                                                    <span><span>Purpose:</span> {{$data->purpose}}</span>
-                                                </span>
-                                                        @endif
+                                            @if($ticket->category === 'erx')
+                                                <div class="font-size-13 mb-1">{{$data->medication}}</div>
+                                                <div class="d-flex align-items-center flex-wrap text-secondary">
+                                                    @if($data->strength)
+                                                        <span class="d-inline-flex align-items-center">
+                                                            <span class="mx-2 text-secondary">•</span>
+                                                            <span>{{$data->strength}}</span>
+                                                        </span>
+                                                    @endif
+                                                    @if($data->route)
+                                                        <span class="d-inline-flex align-items-center">
+                                                            <span class="mx-2 text-secondary">•</span>
+                                                            <span>{{$data->route}}</span>
+                                                        </span>
+                                                    @endif
+                                                    @if($data->frequency)
+                                                        <span class="d-inline-flex align-items-center">
+                                                            <span class="mx-2 text-secondary">•</span>
+                                                            <span>{{$data->frequency}}</span>
+                                                        </span>
+                                                    @endif
+                                                    @if($data->dispense)
+                                                        <span class="d-inline-flex align-items-center">
+                                                            <span class="mx-2 text-secondary">•</span>
+                                                            <span>Dispense:</span> {{$data->dispense}}
+                                                        </span>
+                                                    @endif
+                                                    @if($data->frequency)
+                                                        <span class="d-inline-flex align-items-center">
+                                                            <span class="mx-2 text-secondary">•</span>
+                                                            <span><span>Refills:</span> {{$data->refills}}</span>
+                                                        </span>
+                                                    @endif
+                                                    @if($data->dispense)
+                                                        <span class="d-inline-flex align-items-center">
+                                                            <span class="mx-2 text-secondary">•</span>
+                                                            <span><span>Purpose:</span> {{$data->purpose}}</span>
+                                                        </span>
+                                                    @endif
+                                                </div>
+                                            @endif
+                                            @if($ticket->category === 'lab' || $ticket->category === 'imaging')
+                                                @if(@$data->tests && is_array($data->tests))
+                                                    <div>
+                                                        <span class="text-secondary">Tests:</span>
+                                                        {{implode(", ", $data->tests)}}
                                                     </div>
                                                 @endif
-                                                @if($ticket->category === 'lab' || $ticket->category === 'imaging')
-                                                    @if(@$data->tests && is_array($data->tests))
-                                                        <div>
-                                                            <span class="text-secondary">Tests:</span>
-                                                            {{implode(", ", $data->tests)}}
-                                                        </div>
+                                                @if(@$data->icds && is_array($data->icds))
+                                                    <div>
+                                                        <span class="text-secondary">ICDs:</span>
+                                                        {{implode(", ", $data->icds)}}
+                                                    </div>
+                                                @endif
+                                            @endif
+                                            </td>
+                                        </tr>
+                                        @endif
+                                    @endforeach
+                                    </tbody>
+                                    </table>
+                                @else
+                                    <div class="text-secondary">None</div>
+                                @endif
+                            </div>
+
+                            <hr class="my-2">
+
+                            <p class="font-weight-bold text-secondary mb-2 mr-2">Others open as of {{friendlier_date(date('Y-m-d'))}}</p>
+                            @if($otherOpenTickets && count($otherOpenTickets))
+                                <table class="table table-sm table-bordered mb-0">
+                                    <thead>
+                                    <tr class="bg-light">
+                                        <th class="px-2 text-secondary border-bottom-0 width-30px">Created</th>
+                                        <th class="px-2 text-secondary border-bottom-0 width-30px">Type</th>
+                                        <th class="px-2 text-secondary border-bottom-0 width-30px">Pro</th>
+                                        <th class="px-2 text-secondary border-bottom-0 width-30px">View</th>
+                                        <th class="px-2 text-secondary border-bottom-0 width-30px">Status</th>
+                                        <th class="px-2 text-secondary border-bottom-0">Detail</th>
+                                    </tr>
+                                    </thead>
+                                    <tbody>
+                                    @foreach($otherOpenTickets as $ticket)
+                                        <?php $data = json_decode($ticket->data); ?>
+                                        @if($ticket->category === 'erx' || $ticket->category === 'lab' || $ticket->category === 'imaging')
+                                            <tr class="{{$ticket->is_open ? '' : 'bg-light on-hover-opaque'}}">
+                                                <td class="px-2 text-nowrap">
+                                                    {{friendly_time($ticket->created_at)}}
+                                                </td>
+                                                <td class="px-2 text-nowrap">
+                                                    {{$ticket->category}}
+                                                </td>
+                                                <td class="px-2 text-nowrap">
+                                                    @if($ticket->orderingPro)
+                                                        @if($ticket->orderingPro->id !== $pro->id)
+                                                            <b>{{$ticket->orderingPro->displayName()}}</b>
+                                                        @else
+                                                            You
+                                                        @endif
+                                                    @else
+                                                        -
                                                     @endif
-                                                    @if(@$data->icds && is_array($data->icds))
-                                                        <div>
-                                                            <span class="text-secondary">ICDs:</span>
-                                                            {{implode(", ", $data->icds)}}
+                                                </td>
+                                                <td class="px-2 text-nowrap">
+                                                    <div class="d-flex align-items-center flex-nowrap">
+                                                        <a href="/patients/view/{{$ticket->patient->uid}}/tickets/{{$ticket->category}}/{{$ticket->uid}}?popupmode=1"
+                                                           native target="_blank"
+                                                           class="ticket-popup-trigger note-dashboard-action d-block text-nowrap mr-3">
+                                                            View
+                                                        </a>
+                                                    </div>
+                                                </td>
+                                                <td class="px-2 text-nowrap">
+                                                    {{$ticket->is_open ? 'Open' : 'Closed'}}
+                                                </td>
+                                                <td class="px-2">
+                                                    @if($ticket->category === 'erx')
+                                                        <div class="font-size-13 mb-1">{{$data->medication}}</div>
+                                                        <div class="d-flex align-items-center flex-wrap text-secondary">
+                                                            @if($data->strength)
+                                                                <span class="d-inline-flex align-items-center">
+                                                        <span class="mx-2 text-secondary">•</span>
+                                                        <span>{{$data->strength}}</span>
+                                                    </span>
+                                                            @endif
+                                                            @if($data->route)
+                                                                <span class="d-inline-flex align-items-center">
+                                                        <span class="mx-2 text-secondary">•</span>
+                                                        <span>{{$data->route}}</span>
+                                                    </span>
+                                                            @endif
+                                                            @if($data->frequency)
+                                                                <span class="d-inline-flex align-items-center">
+                                                        <span class="mx-2 text-secondary">•</span>
+                                                        <span>{{$data->frequency}}</span>
+                                                    </span>
+                                                            @endif
+                                                            @if($data->dispense)
+                                                                <span class="d-inline-flex align-items-center">
+                                                        <span class="mx-2 text-secondary">•</span>
+                                                        <span>Dispense:</span> {{$data->dispense}}
+                                                    </span>
+                                                            @endif
+                                                            @if($data->frequency)
+                                                                <span class="d-inline-flex align-items-center">
+                                                        <span class="mx-2 text-secondary">•</span>
+                                                        <span><span>Refills:</span> {{$data->refills}}</span>
+                                                    </span>
+                                                            @endif
+                                                            @if($data->dispense)
+                                                                <span class="d-inline-flex align-items-center">
+                                                        <span class="mx-2 text-secondary">•</span>
+                                                        <span><span>Purpose:</span> {{$data->purpose}}</span>
+                                                    </span>
+                                                            @endif
                                                         </div>
                                                     @endif
+                                                    @if($ticket->category === 'lab' || $ticket->category === 'imaging')
+                                                        @if(@$data->tests && is_array($data->tests))
+                                                            <div>
+                                                                <span class="text-secondary">Tests:</span>
+                                                                {{implode(", ", $data->tests)}}
+                                                            </div>
+                                                        @endif
+                                                        @if(@$data->icds && is_array($data->icds))
+                                                            <div>
+                                                                <span class="text-secondary">ICDs:</span>
+                                                                {{implode(", ", $data->icds)}}
+                                                            </div>
+                                                        @endif
+                                                    @endif
+                                                </td>
+                                            </tr>
+                                        @endif
+                                    @endforeach
+                                    </tbody>
+                                </table>
+                            @else
+                                <div class="text-secondary">None</div>
+                            @endif
+
+                        </div>
+
+                    </div>
+                </div>
+
+                <div class="p-3 border-bottom">
+                    <div class="">
+                        <div class="d-flex align-items-center mb-2">
+                            <p class="font-weight-bold text-secondary m-0 font-size-14">Supply Orders Summary</p>
+                            <span class="mx-2 text-secondary">|</span>
+                            <a native target="_blank"
+                               open-in-stag-popup
+                               update-parent
+                               mc-initer="patient-supply-orders"
+                               title="{{$patient->displayName()}} - Supply Orders"
+                               href="/patients/view/{{$patient->uid}}/supply-orders?popupmode=1&note-uid={{$note->uid}}&filter=active">
+                                Manage Supply Orders
+                            </a>
+                        </div>
+
+                        <div class="p-3 border">
+
+                            <p class="font-weight-bold text-secondary mb-2 mr-2">Associated with this note</p>
+                            <div>
+                                @if($supplyOrdersOnNote && count($supplyOrdersOnNote))
+                                    <table class="table table-sm table-bordered mb-0">
+                                        <thead>
+                                        <tr class="bg-light">
+                                            <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Title</div></th>
+                                            <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Reason</div></th>
+                                            <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Created At</div></th>
+                                            <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Pro Signed?</div></th>
+                                            <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Cancelled?</div></th>
+                                            <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Shipment</div></th>
+                                        </tr>
+                                        </thead>
+                                        <tbody>
+                                        @foreach($supplyOrdersOnNote as $iSupplyOrder)
+                                            <tr class="">
+                                                <td class="px-2">
+                                                    {{ $iSupplyOrder->product->title }}
+                                                </td>
+                                                <td class="px-2">{{ $iSupplyOrder->reason }}</td>
+                                                <td class="px-2">{{ friendlier_date_time($iSupplyOrder->created_at) }}</td>
+                                                <td class="px-2">{{ $iSupplyOrder->is_signed_by_pro ? $iSupplyOrder->signedPro->displayName() : '-' }}</td>
+                                                <td class="px-2">{{ $iSupplyOrder->is_cancelled ? 'Yes' : 'No' }}</td>
+                                                <td class="px-2">
+                                                    @if($iSupplyOrder->shipment_id)
+                                                        <i class="fa fa-building"></i>
+                                                        {{$iSupplyOrder->shipment->status ? $iSupplyOrder->shipment->status : 'CREATED'}}
+                                                    @elseif($iSupplyOrder->is_cleared_for_shipment)
+                                                        <span class="text-info">
+                                                            <i class="fa fa-user-nurse"></i>
+                                                            Cleared for shipment
+                                                        </span>
+                                                    @else
+                                                        <span class="text-warning-mellow">
+                                                            <i class="fa fa-user-nurse"></i>
+                                                            Not cleared for shipment
+                                                        </span>
+                                                    @endif
+                                                </td>
+                                            </tr>
+                                        @endforeach
+                                        </tbody>
+                                    </table>
+                                @else
+                                    <div class="text-secondary">None</div>
+                                @endif
+                            </div>
+
+                            <hr class="my-2">
+
+                            <p class="font-weight-bold text-secondary mb-2 mr-2">Others as of {{friendlier_date(date('Y-m-d'))}}</p>
+                            @if($otherOpenSupplyOrders && count($otherOpenSupplyOrders))
+                                <table class="table table-sm table-bordered mb-0">
+                                    <thead>
+                                    <tr class="bg-light">
+                                        <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Title</div></th>
+                                        <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Reason</div></th>
+                                        <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Created At</div></th>
+                                        <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Pro Signed?</div></th>
+                                        <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Cancelled?</div></th>
+                                        <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Shipment</div></th>
+                                    </tr>
+                                    </thead>
+                                    <tbody>
+                                    @foreach($otherOpenSupplyOrders as $iSupplyOrder)
+                                        <tr class="">
+                                            <td class="px-2">
+                                                {{ $iSupplyOrder->product->title }}
+                                            </td>
+                                            <td class="px-2">{{ $iSupplyOrder->reason }}</td>
+                                            <td class="px-2">{{ friendlier_date_time($iSupplyOrder->created_at) }}</td>
+                                            <td class="px-2">{{ $iSupplyOrder->is_signed_by_pro ? $iSupplyOrder->signedPro->displayName() : '-' }}</td>
+                                            <td class="px-2">{{ $iSupplyOrder->is_cancelled ? 'Yes' : 'No' }}</td>
+                                            <td class="px-2">
+                                                @if($iSupplyOrder->shipment_id)
+                                                    <i class="fa fa-building"></i>
+                                                    {{$iSupplyOrder->shipment->status ? $iSupplyOrder->shipment->status : 'CREATED'}}
+                                                @elseif($iSupplyOrder->is_cleared_for_shipment)
+                                                    <span class="text-info">
+                                                            <i class="fa fa-user-nurse"></i>
+                                                            Cleared for shipment
+                                                        </span>
+                                                @else
+                                                    <span class="text-warning-mellow">
+                                                            <i class="fa fa-user-nurse"></i>
+                                                            Not cleared for shipment
+                                                        </span>
                                                 @endif
                                             </td>
                                         </tr>
-                                    @endif
-                                @endforeach
-                                </tbody>
-                            </table>
-                        @else
-                            <div class="text-secondary">None</div>
-                        @endif
+                                    @endforeach
+                                    </tbody>
+                                </table>
+                            @else
+                                <div class="text-secondary">None</div>
+                            @endif
+
+                        </div>
+
                     </div>
                 </div>
 

+ 1 - 0
resources/views/app/patient/settings.blade.php

@@ -472,6 +472,7 @@
                             class="form-control form-control-sm if-visit-done"
                             onchange="if(this.value === '-- create --') createNewNote('{{$patient->uid}}', '{{$pro->uid}}', '{{date('Y-m-d')}}');">
                         <option value="">-- Visit Note --</option>
+                        <?php $notes = \App\Models\Note::where('client_id', $patient->id)->get() ?>
                         @foreach ($notes as $note)
                             @if(!empty($note->title) && $note->client_id === $patient->id && !$note->is_cancelled)
                                 <option

+ 16 - 6
resources/views/app/patient/tickets.blade.php

@@ -125,13 +125,23 @@
                 $reportsArray[] = $report;
             }
 
+            $allProsLite = [];
+            foreach ($allPros as $allPro) {
+                $allProsLite[] = [
+                    "id" => $allPro->id,
+                    "uid" => $allPro->uid,
+                    "name_first" => $allPro->name_first,
+                    "name_last" => $allPro->name_last,
+                    "displayedName" => $allPro->displayName(),
+                    "displayedInitials" => $allPro->initials()
+                ];
+            }
+
             $allProsFlat = [];
             $paletteIndex = 0;
-            foreach ($allPros as $allPro) {
-                $allPro->displayedName = $allPro->displayName();
-                $allPro->displayedInitials = $allPro->initials();
-                $allProsFlat["pro_" . $allPro->id] = $allPro;
-                $allProsFlat["pro_" . $allPro->id]['colors'] = $palette[$paletteIndex++];
+            foreach ($allProsLite as $allPro) {
+                $allProsFlat["pro_" . $allPro['id']] = $allPro;
+                $allProsFlat["pro_" . $allPro['id']]['colors'] = $palette[$paletteIndex++];
                 if($paletteIndex >= count($palette)) $paletteIndex = 0;
             }
             ?>
@@ -157,7 +167,7 @@
                         // common
                         currentCategory: '',
                         currentItemUid: '',
-                        allPros: {!! json_encode($allPros) !!},
+                        allPros: {!! json_encode($allProsLite) !!},
                         allProsFlat: {!! json_encode($allProsFlat) !!},
                         proToUpdate: '',
                         proTypes: ['Assigned', 'Manager', 'Initiating', 'Ordering'],

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

@@ -467,6 +467,7 @@
                                                             class="form-control form-control-sm if-visit-done"
                                                             onchange="if(this.value === '-- create --') createNewNote('{{$patient->uid}}', '{{$pro->uid}}', '{{date('Y-m-d')}}');">
                                                         <option value="">-- Visit Note --</option>
+                                                        <?php $notes = \App\Models\Note::where('client_id', $patient->id)->get() ?>
                                                         @foreach ($notes as $note)
                                                             @if(!empty($note->title) && $note->client_id === $patient->id && !$note->is_cancelled)
                                                                 <option

+ 2 - 0
storage/debugbar/.gitignore

@@ -0,0 +1,2 @@
+*
+!.gitignore