Patient Portal calendar pop-up fix - bug reported by Mauricio
[openemr.git] / interface / eRx.php
blobe5ddf5848ae0645fe799f5169ba45ec2df8ec78f
1 <?php
2 // +-----------------------------------------------------------------------------+
3 // Copyright (C) 2011 ZMG LLC <sam@zhservices.com>
4 //
5 //
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
18 // A copy of the GNU General Public License is included along with this program:
19 // openemr/interface/login/GnuGPL.html
20 // For more information write to the Free Software
21 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 // Author: Eldho Chacko <eldho@zhservices.com>
24 // Vinish K <vinish@zhservices.com>
26 // +------------------------------------------------------------------------------+
27 //SANITIZE ALL ESCAPES
28 $sanitize_all_escapes=true;
31 //STOP FAKE REGISTER GLOBALS
32 $fake_register_globals=false;
34 require('globals.php');
35 require('eRx_xml.php');
36 $userRole=sqlQuery("select * from users where username=?",array($_SESSION['authUser']));
37 $userRole['newcrop_user_role'] = preg_replace('/erx/','',$userRole['newcrop_user_role']);
38 $msg='';
39 $doc = new DOMDocument();
40 $doc->formatOutput = true;
41 $GLOBALS['total_count']=60;
42 $r = $doc->createElement( "NCScript" );
43 $r->setAttribute('xmlns','http://secure.newcropaccounts.com/interfaceV7');
44 $r->setAttribute('xmlns:NCStandard','http://secure.newcropaccounts.com/interfaceV7:NCStandard');
45 $r->setAttribute('xmlns:xsi','http://www.w3.org/2001/XMLSchema-instance');
46 $doc->appendChild( $r );
48 credentials($doc,$r);
49 user_role($doc,$r);
50 $page=$_REQUEST['page'];
51 destination($doc,$r,$page,$pid);
52 account($doc,$r);
53 if($userRole['newcrop_user_role']!='manager')
55 location($doc,$r);
57 if($userRole['newcrop_user_role']=='doctor' || $page=='renewal')
59 LicensedPrescriber($doc,$r);
61 if($userRole['newcrop_user_role']=='manager' || $userRole['newcrop_user_role']=='admin' || $userRole['newcrop_user_role']=='nurse')
63 Staff($doc,$r);
65 if($userRole['newcrop_user_role']=='supervisingDoctor')
67 SupervisingDoctor($doc,$r);
69 if($userRole['newcrop_user_role']=='midlevelPrescriber')
71 MidlevelPrescriber($doc,$r);
73 $prescIds='';
74 if($pid)
76 Patient($doc,$r,$pid);
77 $active = '';
78 if($GLOBALS['erx_upload_active']==1)
79 $active = 'and active=1';
80 $res_presc=sqlStatement("select id from prescriptions where patient_id=? and erx_source='0' and erx_uploaded='0' $active limit 0,".$GLOBALS['total_count'],array($pid));
81 $presc_limit=sqlNumRows($res_presc);
82 $med_limit=$GLOBALS['total_count']-$presc_limit;
83 while($row_presc=sqlFetchArray($res_presc))
85 $prescIds.=$row_presc['id'].":";
87 $prescIds=preg_replace('/:$/','',$prescIds);
88 if($_REQUEST['id'] || $prescIds)
90 if($_REQUEST['id'])
91 $prescArr=explode(':',$_REQUEST['id']);
92 elseif($prescIds)
93 $prescArr=explode(':',$prescIds);
94 foreach($prescArr as $prescid)
96 if($prescid)
97 OutsidePrescription($doc,$r,$pid,$prescid);
100 else
102 OutsidePrescription($doc,$r,$pid,0);
104 if($res_presc<$GLOBALS['total_count'])
105 PatientMedication($doc,$r,$pid,$med_limit);
107 $xml = $doc->saveXML();
108 $xml = preg_replace('/"/',"'",$xml);
109 //echo $xml."<br><br>";
110 $xml = stripStrings($xml,array('&#xD;'=>'','\t'=>'','\r'=>'','\n'=>''));
111 if($msg)
113 echo htmlspecialchars( xl('The following fields have to be filled to send request.'), ENT_NOQUOTES);
114 echo "<br>";
115 echo $msg;
116 die;
118 //################################################
119 //XML GENERATED BY OPENEMR
120 //################################################
121 //$fh=fopen('click_xml.txt','a');
122 //fwrite($fh,$xml);
123 //echo $xml;
124 //die;
125 //################################################
126 if(!extension_loaded('curl'))
128 echo htmlspecialchars( xl('PHP CURL module should be enabled in your server.'), ENT_NOQUOTES);die;
130 $error = checkError($xml);
131 if($error==0)
133 if($page=='compose'){
134 sqlQuery("update patient_data set soap_import_status=1 where pid=?",array($pid));
136 elseif($page=='medentry'){
137 sqlQuery("update patient_data set soap_import_status=3 where pid=?",array($pid));
139 $prescArr=explode(':',$prescIds);
140 foreach($prescArr as $prescid)
142 sqlQuery("update prescriptions set erx_uploaded='1', active='0' where patient_id=? and id=?",array($pid,$prescid));
145 <script language='JavaScript'>
146 <?php require($GLOBALS['srcdir'] . "/restoreSession.php"); ?>
147 </script>
148 <form name='info' method='post' action="<?php echo getErxPath()?>" onsubmit='return top.restoreSession()'>
149 <input type='submit' style='display:none'>
150 <input type='hidden' id='RxInput' name='RxInput' value="<?php echo $xml;?>">
151 </form>
152 <script type="text/javascript" src="../library/js/jquery.1.3.2.js"></script>
153 <script type='text/javascript'>
154 document.forms[0].submit();
155 </script>
156 <?php
158 else
160 echo htmlspecialchars( xl('NewCrop call failed', ENT_NOQUOTES));