2 // +-----------------------------------------------------------------------------+
3 // Copyright (C) 2011 ZMG LLC <sam@zhservices.com>
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']);
39 $doc = new DOMDocument();
40 $doc->formatOutput
= true;
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 );
50 $page=$_REQUEST['page'];
51 destination($doc,$r,$page,$pid);
53 if($userRole['newcrop_user_role']!='manager')
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')
65 if($userRole['newcrop_user_role']=='supervisingDoctor')
67 SupervisingDoctor($doc,$r);
69 if($userRole['newcrop_user_role']=='midlevelPrescriber')
71 MidlevelPrescriber($doc,$r);
76 Patient($doc,$r,$pid);
77 $res_presc=sqlStatement("select id from prescriptions where patient_id=? and erx_source='0' and erx_uploaded='0'",array($pid));
78 while($row_presc=sqlFetchArray($res_presc))
80 $prescIds.=$row_presc['id'].":";
82 $prescIds=preg_replace('/:$/','',$prescIds);
83 if($_REQUEST['id'] ||
$prescIds)
86 $prescArr=explode(':',$_REQUEST['id']);
88 $prescArr=explode(':',$prescIds);
89 foreach($prescArr as $prescid)
92 OutsidePrescription($doc,$r,$pid,$prescid);
97 OutsidePrescription($doc,$r,$pid,0);
100 $xml = $doc->saveXML();
101 $xml = preg_replace('/"/',"'",$xml);
104 echo htmlspecialchars( xl('The following fields have to be filled to send request.'), ENT_NOQUOTES
);
109 //################################################
110 //XML GENERATED BY OPENEMR
111 //################################################
112 //$fh=fopen('click_xml.txt','w');
116 //################################################
117 if(!extension_loaded('curl'))
119 echo htmlspecialchars( xl('PHP CURL module should be enabled in your server.'), ENT_NOQUOTES
);die;
121 $error = checkError($xml);
124 if($page=='compose'){
125 sqlQuery("update patient_data set soap_import_status=1 where pid=?",array($pid));
127 elseif($page=='medentry'){
128 sqlQuery("update patient_data set soap_import_status=3 where pid=?",array($pid));
130 $prescArr=explode(':',$prescIds);
131 foreach($prescArr as $prescid)
133 sqlQuery("update prescriptions set erx_uploaded='1', active='0' where patient_id=? and id=?",array($pid,$prescid));
136 <script language
='JavaScript'>
137 <?php
require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
139 <form name
='info' method
='post' action
="<?php echo getErxPath()?>" onsubmit
='return top.restoreSession()'>
140 <input type
='submit' style
='display:none'>
141 <input type
='hidden' id
='RxInput' name
='RxInput' value
="<?php echo $xml;?>">
143 <script type
="text/javascript" src
="../library/js/jquery.1.3.2.js"></script
>
144 <script type
='text/javascript'>
145 document
.forms
[0].submit();
151 echo htmlspecialchars( xl('NewCrop call failed', ENT_NOQUOTES
));