Vijayakrishnan пре 3 година
родитељ
комит
e415bdd62b

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

@@ -27,6 +27,7 @@ use Illuminate\Http\Request;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\File;
 
+use Illuminate\Support\Facades\Http;
 use PDF;
 
 class PatientController extends Controller
@@ -432,6 +433,37 @@ class PatientController extends Controller
         }
     }
 
+    public function transmitPrescription(Request $request, Erx $prescription){
+
+        // re-generate pdf with cover sheet as first page and save it to FS
+        $filePath = config('app.temp_dir') . "/{$prescription->uid}.pdf";
+        $pdf = PDF::loadView('app.patient.prescriptions.pdf.pdf-preview-with-cover-sheet', compact('prescription'));
+        $pdf->save($filePath);
+
+        // send it along with the rest of the params to /api/erx/transmit [multi-part POST]
+        $url =  config('stag.backendUrl') . '/erx/transmit';
+        $params = [
+            "uid" => $request->input('uid'),
+            "toWho" => $request->input('toWho'),
+            "toEmail" => $request->input('toEmail'),
+            "toFaxNumber" => $request->input('toFaxNumber'),
+            "toFaxNumberAttentionLine" => $request->input('toFaxNumberAttentionLine'),
+            "toFaxNumberCoverSheetMemo" => $request->input('toFaxNumberCoverSheetMemo'),
+        ];
+        if($request->input('copyToPatient')) {
+            $params["copyToPatientFaxNumber"] = $request->input('copyToPatientFaxNumber');
+            $params["copyToPatientEmail"] = $request->input('copyToPatientEmail');
+        }
+        $pdf = fopen($filePath, 'r');
+        $response = Http
+            ::attach('pdfSystemFile', $filePath, "{$prescription->uid}.pdf")
+            ->withHeaders(['sessionKey' => $request->cookie('sessionKey')])
+            ->post($url, $params)
+            ->json();
+        return $response;
+
+    }
+
     public function supplyOrders(Request $request, Client $patient, SupplyOrder $supplyOrder = null)
     {
         $products = Product::where('is_active', true)->orderBy('created_at', 'desc')->get();

+ 2 - 0
config/app.php

@@ -67,6 +67,8 @@ return [
 
     'asset_version' => 6,
 
+    'temp_dir' => env('TEMP_DIR'),
+
     /*
     |--------------------------------------------------------------------------
     | Application Timezone

+ 1 - 1
public/css/style.css

@@ -1527,7 +1527,7 @@ button.note-templates-trigger-assessment {
 .collapsible-tbody.collapsed {
     display: none;
 }
-#send-fax-pdf-preview {
+#send-fax-pdf-preview, #transmit-pdf-preview {
     max-height: 350px;
     overflow: auto;
     box-shadow: 0 0 2px #ccc;

+ 43 - 26
resources/views/app/patient/prescriptions/index.blade.php

@@ -232,7 +232,7 @@
                         <a native target="_blank"
                            :href="'/prescription-download-as-pdf/' + currentPrescription.uid">Download</a>
                         <span class="mx-2 text-secondary">|</span>
-                        <a href="#" v-on:click.prevent="sendFax(currentPrescription)">Send Fax</a>
+                        <a href="#" v-on:click.prevent="transmit(currentPrescription)">Transmit</a>
                     </div>
                 </div>
             </div>
@@ -248,13 +248,14 @@
         @include('app.patient.prescriptions.sign-as-hcp-form')
         @include('app.patient.prescriptions.pro-status-form')
         @include('app.patient.prescriptions.client-status-form')
-        @include('app.patient.prescriptions.send-fax-form')
+        @include('app.patient.prescriptions.transmit-form')
     </div>
     <script>
         (function() {
 
             <?php
             $prescriptions = $patient->prescriptions;
+            $currentPrescription = null;
             foreach ($prescriptions as $prescription) {
                 if($prescription->clinical_detail_json) {
                     $prescription->clinical_detail_json = json_decode($prescription->clinical_detail_json);
@@ -266,6 +267,10 @@
                 $prescription->created_at_friendly_short = friendlier_date_time($prescription->created_at, false);
                 $prescription->hcpProDisplayName = $prescription->hcpPro ? $prescription->hcpPro->displayName() : '-';
                 $prescription->hcpProUid = $prescription->hcpPro ? $prescription->hcpPro->uid : '';
+
+//                if(!!@$currentErx && $currentErx->uid === $prescription->uid) {
+//
+//                }
             }
             ?>
 
@@ -393,11 +398,18 @@
                             status: '',
                             memo: '',
                         },
-                        currentPrescriptionFax: {
+                        currentPrescriptionTransmit: {
                             uid: '',
-                            faxNumber: '',
+                            logistics: '',
+                            toWho: '',
+                            toEmail: '',
+                            toFaxNumber: '',
+                            toFaxNumberAttentionLine: '',
+                            toFaxNumberCoverSheetMemo: '',
+                            copyToPatient: false,
+                            copyToPatientFaxNumber: '',
+                            copyToPatientEmail: '',
                         },
-
                     },
                     methods: {
 
@@ -655,19 +667,26 @@
                             return _s;
                         },
 
-                        // send fax
-                        sendFax: function(_prescription) {
-                            this.currentPrescriptionFax = {
+                        // transmit
+                        transmit: function(_prescription) {
+                            this.currentPrescriptionTransmit = {
                                 uid: _prescription.uid,
-                                faxNumber: _prescription.logistics_detail_json && _prescription.logistics_detail_json.facilityFax ?
-                                    _prescription.logistics_detail_json.facilityFax : '',
+                                toWho: _prescription.logistics_detail_json ? _prescription.logistics_detail_json.facilityName : '',
+                                toEmail: '',
+                                toFaxNumber: _prescription.logistics_detail_json ? _prescription.logistics_detail_json.facilityFax : '',
+                                toFaxNumberAttentionLine: '',
+                                toFaxNumberCoverSheetMemo: '',
+                                copyToPatient: false,
+                                copyToPatientFaxNumber: '{{$patient->cell_number}}',
+                                copyToPatientEmail: '{{$patient->email_address}}',
+                                _token: '{{csrf_token()}}'
                             };
                             Vue.nextTick(() => {
-                                showStagPopup('send-fax-popup');
-                                this.sendFaxModalPDFPreview();
+                                showStagPopup('transmit-popup');
+                                this.transmitModalPDFPreview();
                             });
                         },
-                        sendFaxModalPDFPreview: function() {
+                        transmitModalPDFPreview: function() {
 
                             let _loadedPDF = null, _numPages = 1, _page = 1;
 
@@ -677,7 +696,7 @@
                                 _numPages = 1;
                                 _page = 1;
 
-                                $('#send-fax-pdf-preview>canvas').remove();
+                                $('#transmit-pdf-preview>canvas').remove();
 
                                 let url = _url;
                                 let pdfjsLib = window['pdfjs-dist/build/pdf'];
@@ -699,7 +718,7 @@
                                     // create canvas
                                     let canvasElement = $('<canvas/>')
                                         .addClass('pdf-viewer-page pdf-preview-page')
-                                        .appendTo('#send-fax-pdf-preview');
+                                        .appendTo('#transmit-pdf-preview');
 
                                     let canvas = canvasElement[0];
                                     let viewport = page.getViewport({scale: 0.75});
@@ -721,19 +740,17 @@
                                 });
                             }
 
-                            _load('/prescription-download-as-pdf/' + this.currentPrescriptionFax.uid);
+                            _load('/prescription-download-as-pdf/' + this.currentPrescriptionTransmit.uid);
                         },
-                        doSendFax: function (_item) {
-                            /*$.post('/api/ticketFax/create', {
-                                    faxNumber: this.faxNumber,
-                                    ticketUid: this[this.currentCategory + 'PopupItem'].uid
-                                },
-                                (_data) => {
-                                    this.reloadPopupItem(this.currentCategory);
+                        doTransmit: function (_item) {
+                            let payload = JSON.parse(JSON.stringify(this.currentPrescriptionTransmit));
+                            $.post('/prescription-transmit/' + payload.uid, payload, _data => {
+                                if(!hasResponseError(_data)) {
+                                    toastr.success('Transmission initiated');
                                     closeStagPopup();
-                                },
-                                'json');*/
-                            alert(1);
+                                    fastReload();
+                                }
+                            }, 'json');
                             closeStagPopup();
                         },
 

Разлика између датотеке није приказан због своје велике величине
+ 13 - 0
resources/views/app/patient/prescriptions/pdf/pdf-preview-with-cover-sheet.blade.php


+ 0 - 23
resources/views/app/patient/prescriptions/send-fax-form.blade.php

@@ -1,23 +0,0 @@
-<div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="send-fax-popup">
-    <form method="POST" class="overflow-visible">
-        <h3 class="stag-popup-title mb-2">
-            <span><i class="fa fa-fax text-secondary font-size-13"></i> Send Fax</span>
-            <a href="#" class="ml-auto text-secondary"
-               onclick="return closeStagPopup()"><i class="fa fa-times"></i></a>
-        </h3>
-        <div class="mb-3">
-            <p class="text-secondary text-sm mb-2 text-center">Document Preview</p>
-            <div id="send-fax-pdf-preview">
-
-            </div>
-        </div>
-        <div class="form-group mb-2">
-            <label class="font-weight-bold mb-1">Fax Number</label>
-            <input type="text" v-model="currentPrescriptionFax.faxNumber" class="form-control">
-        </div>
-        <div class="d-flex align-items-center justify-content-center mt-3">
-            <button type="button" class="btn btn-sm btn-primary mr-2" v-on:click.prevent="doSendFax()">Submit</button>
-            <button type="button" class="btn btn-sm btn-default border" onclick="return closeStagPopup()">Cancel</button>
-        </div>
-    </form>
-</div>

+ 66 - 0
resources/views/app/patient/prescriptions/transmit-form.blade.php

@@ -0,0 +1,66 @@
+<div class="stag-popup stag-popup-sm mcp-theme-1" stag-popup-key="transmit-popup">
+    <form method="POST" class="overflow-visible">
+        <h3 class="stag-popup-title mb-2">
+            <span><i class="fa fa-fax text-secondary font-size-13"></i> Transmit via Fax or Secure Email</span>
+            <a href="#" class="ml-auto text-secondary"
+               onclick="return closeStagPopup()"><i class="fa fa-times"></i></a>
+        </h3>
+        <div class="mb-3 pb-3 border-bottom">
+            <p class="text-secondary text-sm mb-2 text-center">Document Preview</p>
+            <div id="transmit-pdf-preview">
+
+            </div>
+        </div>
+        <div class="mb-2">
+            <label class=" mb-1">To</label>
+            <input type="text" v-model="currentPrescriptionTransmit.toWho" class="form-control">
+        </div>
+        <div class="row mb-2">
+            <div class="col-6 pr-0">
+                <div class="">
+                    <label class=" mb-1">Email</label>
+                    <input type="text" v-model="currentPrescriptionTransmit.toEmail" class="form-control">
+                </div>
+            </div>
+            <div class="col-6">
+                <div class="">
+                    <label class=" mb-1">Fax Number</label>
+                    <input type="text" v-model="currentPrescriptionTransmit.toFaxNumber" class="form-control">
+                </div>
+            </div>
+        </div>
+        <div class="mb-2">
+            <label class=" mb-1">Fax Attention Line</label>
+            <input type="text" v-model="currentPrescriptionTransmit.toFaxNumberAttentionLine" class="form-control">
+        </div>
+        <div class="mb-2">
+            <label class=" mb-1">Fax Cover Sheet Memo</label>
+            <input type="text" v-model="currentPrescriptionTransmit.toFaxNumberCoverSheetMemo" class="form-control">
+        </div>
+        <div class="mb-2 pt-2">
+            <label class=" mb-1 d-inline-flex align-items-baseline">
+                <input type="checkbox" v-model="currentPrescriptionTransmit.copyToPatient" class="mr-2">
+                Transmit Copy to Patient
+            </label>
+        </div>
+        <div class="row mb-2" v-show="currentPrescriptionTransmit.copyToPatient">
+            <div class="col-6 pr-0">
+                <div class="">
+                    <label class=" mb-1">Patient Email</label>
+                    <input type="text" v-model="currentPrescriptionTransmit.copyToPatientEmail" class="form-control">
+                </div>
+            </div>
+            <div class="col-6">
+                <div class="">
+                    <label class=" mb-1">Patient Fax Number</label>
+                    <input type="text" v-model="currentPrescriptionTransmit.copyToPatientFaxNumber" class="form-control">
+                </div>
+            </div>
+        </div>
+
+        <div class="d-flex align-items-center justify-content-center mt-3">
+            <button type="button" class="btn btn-sm btn-primary mr-2" v-on:click.prevent="doTransmit()">Submit</button>
+            <button type="button" class="btn btn-sm btn-default border" onclick="return closeStagPopup()">Cancel</button>
+        </div>
+    </form>
+</div>

+ 1 - 0
routes/web.php

@@ -46,6 +46,7 @@ Route::post("/process-appointment-confirmation", 'GuestController@processAppoint
 
 Route::get('/ticket-download-as-pdf/{ticket}', 'TicketController@downloadAsPdf')->name('ticket-download-as-pdf');
 Route::get('/prescription-download-as-pdf/{prescription}', 'PatientController@downloadPrescriptionAsPdf')->name('prescription-download-as-pdf');
+Route::any('/prescription-transmit/{prescription}', 'PatientController@transmitPrescription')->name('prescription-transmit');
 Route::get('/get-ticket-faxes/{ticket}', 'TicketController@getTicketFaxes')->name('get-ticket-faxes');
 
 Route::middleware('pro.auth')->group(function () {

Неке датотеке нису приказане због велике количине промена