소스 검색

Erx UI - Send fax (incomplete)

Vijayakrishnan 3 년 전
부모
커밋
77bad158e8
2개의 변경된 파일113개의 추가작업 그리고 2개의 파일을 삭제
  1. 90 2
      resources/views/app/patient/prescriptions/index.blade.php
  2. 23 0
      resources/views/app/patient/prescriptions/send-fax-form.blade.php

+ 90 - 2
resources/views/app/patient/prescriptions/index.blade.php

@@ -238,7 +238,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="showSendFaxPopup()">Send Fax</a>
+                        <a href="#" v-on:click.prevent="sendFax(currentPrescription)">Send Fax</a>
                     </div>
                 </div>
             </div>
@@ -254,6 +254,7 @@
         @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')
     </div>
     <script>
         (function() {
@@ -398,6 +399,11 @@
                             status: '',
                             memo: '',
                         },
+                        currentPrescriptionFax: {
+                            uid: '',
+                            faxNumber: '',
+                        },
+
                     },
                     methods: {
 
@@ -653,7 +659,89 @@
                             _s = _s.toLowerCase().replaceAll('_', ' ');
                             _s = _s[0].toUpperCase() + _s.substr(1);
                             return _s;
-                        }
+                        },
+
+                        // send fax
+                        sendFax: function(_prescription) {
+                            this.currentPrescriptionFax = {
+                                uid: _prescription.uid,
+                                faxNumber: _prescription.logistics_detail_json && _prescription.logistics_detail_json.facilityFax ?
+                                    _prescription.logistics_detail_json.facilityFax : '',
+                            };
+                            Vue.nextTick(() => {
+                                showStagPopup('send-fax-popup');
+                                this.sendFaxModalPDFPreview();
+                            });
+                        },
+                        sendFaxModalPDFPreview: function() {
+
+                            let _loadedPDF = null, _numPages = 1, _page = 1;
+
+                            function _load(_url) {
+
+                                _loadedPDF = null;
+                                _numPages = 1;
+                                _page = 1;
+
+                                $('#send-fax-pdf-preview>canvas').remove();
+
+                                let url = _url;
+                                let pdfjsLib = window['pdfjs-dist/build/pdf'];
+                                pdfjsLib.GlobalWorkerOptions.workerSrc = '//mozilla.github.io/pdf.js/build/pdf.worker.js';
+                                let loadingTask = pdfjsLib.getDocument(url);
+                                loadingTask.promise.then(function (pdf) {
+                                    _numPages = pdf.numPages;
+                                    _loadedPDF = pdf;
+                                    _page = 1;
+                                    _render();
+                                }, function (reason) {
+                                    // reason.message;
+                                });
+                            }
+                            function _render() {
+
+                                _loadedPDF.getPage(_page).then(function (page) {
+
+                                    // create canvas
+                                    let canvasElement = $('<canvas/>')
+                                        .addClass('pdf-viewer-page pdf-preview-page')
+                                        .appendTo('#send-fax-pdf-preview');
+
+                                    let canvas = canvasElement[0];
+                                    let viewport = page.getViewport({scale: 0.75});
+                                    let context = canvas.getContext('2d');
+                                    canvas.height = viewport.height;
+                                    canvas.width = viewport.width;
+                                    const $canvas = $(canvas);
+                                    let renderContext = {
+                                        canvasContext: context,
+                                        viewport: viewport
+                                    };
+                                    let renderTask = page.render(renderContext);
+                                    renderTask.promise.then(function () {
+                                        if(_page < _numPages) {
+                                            _page++;
+                                            _render();
+                                        }
+                                    });
+                                });
+                            }
+
+                            _load('/prescription-download-as-pdf/' + this.currentPrescriptionFax.uid);
+                        },
+                        doSendFax: function (_item) {
+                            /*$.post('/api/ticketFax/create', {
+                                    faxNumber: this.faxNumber,
+                                    ticketUid: this[this.currentCategory + 'PopupItem'].uid
+                                },
+                                (_data) => {
+                                    this.reloadPopupItem(this.currentCategory);
+                                    closeStagPopup();
+                                },
+                                'json');*/
+                            alert(1);
+                            closeStagPopup();
+                        },
 
                         // cancel, etc.
 

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

@@ -0,0 +1,23 @@
+<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>