Highway to PSR2
[openemr.git] / interface / forms / eye_mag / taskman.php
blob5bb5a8cff52ca110aadb0463f8750416f339b3fc
1 <?php
2 /**
3 * forms/eye_mag/taskman.php
5 * This file is the gateway to a practice's fax server.
6 * It uses an email fax gateway that is behind the corporate
7 * firewall, thus it is HIPPA compliant (at least TO the fax machine)
9 * Copyright (C) 2016 Raymond Magauran <magauran@MedFetch.com>
11 * LICENSE: This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 3
14 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
22 * @package OpenEMR
23 * @author Ray Magauran <magauran@MedFetch.com>
24 * @link http://www.open-emr.org
31 $form_name = "eye_mag";
32 $form_folder="eye_mag";
33 // larry :: hack add for command line version
34 if (!$_SERVER['REQUEST_URI']) {
35 $_SERVER['REQUEST_URI']=$_SERVER['PHP_SELF'];
38 if (!$_SERVER['SERVER_NAME']) {
39 $_SERVER['SERVER_NAME']='localhost';
42 if (!$_SERVER['HTTP_HOST']) {
43 $_SERVER['HTTP_HOST']='default'; //need to figure out how to do this for non-default installs
46 $ignoreAuth=1;
48 require_once("../../globals.php");
49 require_once("$srcdir/acl.inc");
50 require_once("$srcdir/html2pdf/vendor/autoload.php");
51 require_once("$srcdir/api.inc");
52 require_once("$srcdir/forms.inc");
53 require_once("php/".$form_name."_functions.php");
54 require_once($srcdir . "/../controllers/C_Document.class.php");
55 require_once($srcdir . "/documents.php");
57 require_once("$srcdir/patient.inc");
58 require_once("$srcdir/options.inc.php");
59 require_once("$srcdir/acl.inc");
60 require_once("$srcdir/lists.inc");
61 require_once("$srcdir/report.inc");
62 require_once("$srcdir/html2pdf/html2pdf.class.php");
63 require_once("php/taskman_functions.php");
64 require_once("report.php");
68 /**
70 * Script to fax something to someone somewhere.
71 * This is currently set up for an in house secure email-fax gateway.
72 * This will need to be modified to use a HylaFax server if that is what you use.
74 * We will need these as variables then:
75 * From, To, Object(s) to send
76 * These values are already in the openEMR DB, we just have to put them together correctly.
78 * The first use case scenario is to fax the report of today's visit to a PCP/Referring doctor.
79 * The second scenario is the creation (or re-creation) of a Report of the encounter.
80 * To lighten loads, consider breaking these tasks up into separate tasks via cron or even using a different server
81 * to process these tasks, if in a multi-server environment. Or run this file with openEMR's "background_services".
82 * Use a new table (form_taskman) to delineate this process.
83 * 1. Create the Task to be performed: send it to DB table from the browser.
84 * 2. Cron job to scour this table, performing tasks as loads allow (check server load? <-- not implemented)
85 * 3. If the Object is ready to be created, create it. (e-signed required? <-- not implemented)
86 * 4. If the Object is created and it is a Report, Flag DB done (completed =1).
87 * 5. If the Object is created and it is a Fax, send it, and Flag DB done.
90 global $encounter;
91 global $pid;
92 global $visit_date;
93 global $PDF_OUTPUT;
94 global $form_id;
95 global $task;
96 global $send;
98 $PDF_OUTPUT='1';
99 // If this is a request to make a task, make it.
100 $ajax_req = $_REQUEST;
102 if ($_REQUEST['action']=='make_task') {
103 make_task($ajax_req);
106 if ($_REQUEST['action']=='show_task') {
107 show_task($ajax_req);
110 // Get the list of Tasks and process them one-by-one
111 // unless this is a call from the web, then just do the task at hand
112 // or should the web not do these at all, leave them to the background processor?
115 $query = "SELECT * FROM form_taskman where PATIENT_ID=? AND (COMPLETED is NULL or COMPLETED != '1') order by REQ_DATE";
116 $result = sqlStatement($query, array($ajax_req['pid']));
117 while ($task= sqlFetchArray($result)) {
118 $send = process_tasks($task);
119 if ($_REQUEST['action']=='make_task') {
120 echo json_encode($send);
121 exit;
125 $send['comments'] = "Nothing new to do!";
126 echo json_encode($send);
127 exit;