Forráskód Böngészése

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

= 3 éve
szülő
commit
4c02c16f7c

+ 0 - 1
app/Console/Commands/clientsToGsheet.php

@@ -4,7 +4,6 @@ namespace App\Console\Commands;
 
 use App\Models\BDTDevice;
 use App\Models\Client;
-use App\Models\SimpleProduct;
 use Google\Service\Sheets\ValueRange;
 use Google_Client;
 use Illuminate\Console\Command;

+ 99 - 0
app/Http/Controllers/GsheetController.php

@@ -0,0 +1,99 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Exception;
+use Google\Service\Sheets\ValueRange;
+use Google_Client;
+use Illuminate\Console\Command;
+use Revolution\Google\Sheets\Facades\Sheets;
+use Revolution\Google\Sheets\Sheets as SheetsSheets;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
+
+class GsheetController extends Controller
+{
+    
+
+    public function testGsheet(){
+        $sql = 'SELECT uid, name_first, name_last FROM client';
+        $sqlParams = [];
+
+        $values = $this->getValues($sql, $sqlParams);
+
+        $spreadsheetId = '1jRCkukeSfZufY8gpKSGYgv9cgeDbA1ZYP4pKJhyPP_o';
+        $sheetName = 'Sheet1';
+        return $this->exportToGsheet($sql, $sqlParams, $spreadsheetId, $sheetName);
+
+    }
+
+
+    private function exportToGsheet($sql, $sqlParams, $spreadsheetId, $sheetName){
+       
+        $client = $this->getApiClient();
+        $service = new \Google\Service\Sheets($client);
+
+        
+        $values = $this->getValues($sql, $sqlParams);
+
+        $range = $sheetName.'!A1:V1';
+        $body = new ValueRange([
+            'values' => $values
+        ]);
+        $params = [
+           'valueInputOption' => 'RAW'
+        ];
+
+        $result = $service->spreadsheets_values->append($spreadsheetId, $range, $body, $params);
+
+        return $result;
+    }
+
+
+    function getApiClient(){
+      
+        $KEY_FILE_LOCATION = storage_path('stag-gsheets-d9ead2f78b4b.json');
+
+        $client = new Google_Client();
+        $client->setApplicationName("My Rooster Admin");
+        $client->setAuthConfig($KEY_FILE_LOCATION);
+        
+        $client->setScopes([\Google\Service\Sheets::DRIVE, \Google\Service\Sheets::SPREADSHEETS]);
+
+        return $client;
+
+    }
+
+
+    private function getValues($sql, $sqlParams){
+
+        $values = [];
+
+        $raws = DB::select($sql, $sqlParams);
+
+        if(!count($raws)){
+            throw new \Exception("No data");
+        }
+
+        $firstRaw = $raws[0];
+
+        $headers = [];
+        foreach($firstRaw as $k => $val) {
+            $headers[] = $k;
+        }
+        $values[] = $headers;
+
+        
+        foreach($raws as $raw){
+            $rawStr = '';
+            foreach($headers as $header ){
+                $rawStr = $rawStr.$raw->$header.'~~';
+            }
+            $values[] = explode('~~', $rawStr);
+        }
+        
+       
+        return $values;
+    }
+
+}

+ 8 - 4
resources/views/app/patient/vitals-settings/bmi-management-summary.blade.php

@@ -10,8 +10,10 @@
     <span class="text-secondary text-nowrap">Weight (usual):</span>
     <div class="ml-2">
       @if($patient->usual_weight_in_pounds_min)
-        Between <b>{{$patient->usual_weight_in_pounds_min}}</b>
-        and <b>{{$patient->usual_weight_in_pounds_max}}</b>
+        <b>{{$patient->usual_weight_in_pounds_min}}</b>
+        @if($patient->usual_weight_in_pounds_max)
+        - <b>{{$patient->usual_weight_in_pounds_max}}</b>
+        @endif
       @else
       <span>-</span>
       @endif
@@ -22,8 +24,10 @@
     <span class="text-secondary text-nowrap">BMI (usual):</span>
     <div class="ml-2">
       @if($patient->usual_bmi_min)
-        Between <span class="text-nowrap"><b>{{$patient->usual_bmi_min}}</b> {{$patient->usual_bmi_min_category}}</span>
-        and <span class="text-nowrap"><b>{{$patient->usual_bmi_max}}</b> {{$patient->usual_bmi_max_category}}</span>
+        <span class="text-nowrap"><b>{{$patient->usual_bmi_min}}</b> {{$patient->usual_bmi_min_category}}</span>
+        @if($patient->usual_bmi_max)
+        - <span class="text-nowrap"><b>{{$patient->usual_bmi_max}}</b> {{$patient->usual_bmi_max_category}}</span>
+        @endif
       @else
       <span>-</span>
       @endif

+ 9 - 9
resources/views/app/patient/vitals-settings/bp-management-form.blade.php

@@ -20,7 +20,7 @@
                                 <input type="text" class="inline-input-underlined width-50" name="usualAmRestingSbpMin" value="{{ $patient->usual_am_resting_sbp_min }}" />
                                 <span>/</span>
                                 <input type="text" class="inline-input-underlined width-50 mr-3" name="usualAmRestingDbpMin" value="{{ $patient->usual_am_resting_dbp_min }}" />
-                                <span>mm Hg Pulse:</span>
+                                <span>Pulse:</span>
                                 <input type="text" class="inline-input-underlined width-50" name="usualAmRestingPulseMin" value="{{ $patient->usual_am_resting_pulse_min }}" />
                                 <span>BPM</span>
                             </div>
@@ -31,7 +31,7 @@
                                 <input type="text" class="inline-input-underlined width-50" name="usualAmRestingSbpMax" value="{{ $patient->usual_am_resting_sbp_max }}" />
                                 <span>/</span>
                                 <input type="text" class="inline-input-underlined width-50 mr-3" name="usualAmRestingDbpMax" value="{{ $patient->usual_am_resting_dbp_max }}" />
-                                <span>mm Hg Pulse:</span>
+                                <span>Pulse:</span>
                                 <input type="text" class="inline-input-underlined width-50" name="usualAmRestingPulseMax" value="{{ $patient->usual_am_resting_pulse_max }}" />
                                 <span>BPM</span>
                             </div>
@@ -47,7 +47,7 @@
                                     <input type="text" class="inline-input-underlined width-50" name="usualPmRestingSbpMin" value="{{ $patient->usual_pm_resting_sbp_min }}" />
                                     <span>/</span>
                                     <input type="text" class="inline-input-underlined width-50 mr-3" name="usualPmRestingDbpMin" value="{{ $patient->usual_pm_resting_dbp_min }}" />
-                                    <span>mm Hg Pulse:</span>
+                                    <span>Pulse:</span>
                                     <input type="text" class="inline-input-underlined width-50" name="usualPmRestingPulseMin" value="{{ $patient->usual_pm_resting_pulse_min }}" />
                                     <span>BPM</span>
                                 </div>
@@ -57,7 +57,7 @@
                                     <input type="text" class="inline-input-underlined width-50" name="usualPmRestingSbpMax" value="{{ $patient->usual_pm_resting_sbp_max }}" />
                                     <span>/</span>
                                     <input type="text" class="inline-input-underlined width-50 mr-3" name="usualPmRestingDbpMax" value="{{ $patient->usual_pm_resting_dbp_max }}" />
-                                    <span>mm Hg Pulse:</span>
+                                    <span>Pulse:</span>
                                     <input type="text" class="inline-input-underlined width-50" name="usualPmRestingPulseMax" value="{{ $patient->usual_pm_resting_pulse_max }}" />
                                     <span>BPM</span>
                                 </div>
@@ -87,7 +87,7 @@
                             <input type="text" class="inline-input-underlined width-50" name="idealAmRestingSbpMin" value="{{ $patient->ideal_am_resting_sbp_min }}" />
                             <span>/</span>
                             <input type="text" class="inline-input-underlined width-50 mr-3" name="idealAmRestingDbpMin" value="{{ $patient->ideal_am_resting_dbp_min }}" />
-                            <span>mm Hg Pulse:</span>
+                            <span>Pulse:</span>
                             <input type="text" class="inline-input-underlined width-50" name="idealAmRestingPulse" value="{{ $patient->ideal_am_resting_pulse }}" />
                             <span>BPM</span>
                         </div>
@@ -102,7 +102,7 @@
                             <input type="text" class="inline-input-underlined width-50" name="redAlertWhenSbpAbove" value="{{ $patient->red_alert_when_sbp_above }}" />
                             <span>/</span>
                             <input type="text" class="inline-input-underlined width-50 mr-3" name="redAlertWhenDbpAbove" value="{{ $patient->red_alert_when_dbp_above }}" />
-                            <span>mm Hg Pulse:</span>
+                            <span>Pulse:</span>
                             <input type="text" class="inline-input-underlined width-50" name="redAlertWhenPulseAbove" value="{{ $patient->red_alert_when_pulse_above }}" />
                             <span>BPM</span>
                         </div>
@@ -112,7 +112,7 @@
                             <input type="text" class="inline-input-underlined width-50" name="redAlertWhenSbpBelow" value="{{ $patient->red_alert_when_sbp_below }}" />
                             <span>/</span>
                             <input type="text" class="inline-input-underlined width-50 mr-3" name="redAlertWhenDbpBelow" value="{{ $patient->red_alert_when_dbp_below }}" />
-                            <span>mm Hg Pulse:</span>
+                            <span>Pulse:</span>
                             <input type="text" class="inline-input-underlined width-50" name="redAlertWhenPulseBelow" value="{{ $patient->red_alert_when_pulse_below }}" />
                             <span>BPM</span>
                         </div>
@@ -125,7 +125,7 @@
                             <input type="text" class="inline-input-underlined width-50" name="yellowAlertWhenSbpAbove" value="{{ $patient->yellow_alert_when_sbp_above }}" />
                             <span>/</span>
                             <input type="text" class="inline-input-underlined width-50 mr-3" name="yellowAlertWhenDbpAbove" value="{{ $patient->yellow_alert_when_dbp_above }}" />
-                            <span>mm Hg Pulse:</span>
+                            <span>Pulse:</span>
                             <input type="text" class="inline-input-underlined width-50" name="yellowAlertWhenPulseAbove" value="{{ $patient->yellow_alert_when_pulse_above }}" />
                             <span>BPM</span>
                         </div>
@@ -135,7 +135,7 @@
                             <input type="text" class="inline-input-underlined width-50" name="yellowAlertWhenSbpBelow" value="{{ $patient->yellow_alert_when_sbp_below }}" />
                             <span>/</span>
                             <input type="text" class="inline-input-underlined width-50 mr-3" name="yellowAlertWhenDbpBelow" value="{{ $patient->yellow_alert_when_dbp_below }}" />
-                            <span>mm Hg Pulse:</span>
+                            <span>Pulse:</span>
                             <input type="text" class="inline-input-underlined width-50" name="yellowAlertWhenPulseBelow" value="{{ $patient->yellow_alert_when_pulse_below }}" />
                             <span>BPM</span>
                         </div>

+ 4 - 0
routes/web.php

@@ -200,6 +200,8 @@ Route::middleware('pro.auth')->group(function () {
         });
     });
 
+    //Route::get('test-gsheet', 'GsheetController@testGsheet');
+
     Route::name('admin.')->prefix('a')->middleware('pro.auth.admin')->group(function () {
         // TODO
 
@@ -217,6 +219,8 @@ Route::middleware('pro.auth')->group(function () {
         Route::get('reports', 'AdminController@reports')->name('reports');
         Route::get('supply-orders', 'AdminController@supply_orders')->name('supply_orders');
         Route::get('get-create-new-patient-script-template', 'AdminController@getCreateNewPatientScriptTemplate')->name('getCreateNewPatientScriptTemplate');
+    
+       
     });
 
     Route::name('practice-management.')->prefix('practice-management')->group(function () {