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']);
41 $doc = new DOMDocument();
42 $doc->formatOutput
= true;
43 $GLOBALS['total_count']=60;
44 $r = $doc->createElement( "NCScript" );
45 $r->setAttribute('xmlns','http://secure.newcropaccounts.com/interfaceV7');
46 $r->setAttribute('xmlns:NCStandard','http://secure.newcropaccounts.com/interfaceV7:NCStandard');
47 $r->setAttribute('xmlns:xsi','http://www.w3.org/2001/XMLSchema-instance');
48 $doc->appendChild( $r );
52 $page=$_REQUEST['page'];
53 destination($doc,$r,$page,$pid);
55 if($userRole['newcrop_user_role']!='manager')
59 if($userRole['newcrop_user_role']=='doctor' ||
$page=='renewal')
61 LicensedPrescriber($doc,$r);
63 if($userRole['newcrop_user_role']=='manager' ||
$userRole['newcrop_user_role']=='admin' ||
$userRole['newcrop_user_role']=='nurse')
67 if($userRole['newcrop_user_role']=='supervisingDoctor')
69 SupervisingDoctor($doc,$r);
71 if($userRole['newcrop_user_role']=='midlevelPrescriber')
73 MidlevelPrescriber($doc,$r);
78 $allergy=Patient($doc,$r,$pid);
80 if($GLOBALS['erx_upload_active']==1)
81 $active = 'and active=1';
82 $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));
83 $presc_limit=sqlNumRows($res_presc);
84 $med_limit=$GLOBALS['total_count']-$presc_limit;
85 while($row_presc=sqlFetchArray($res_presc))
87 $prescIds.=$row_presc['id'].":";
89 $prescIds=preg_replace('/:$/','',$prescIds);
90 if($_REQUEST['id'] ||
$prescIds)
93 $prescArr=explode(':',$_REQUEST['id']);
95 $prescArr=explode(':',$prescIds);
96 foreach($prescArr as $prescid)
99 OutsidePrescription($doc,$r,$pid,$prescid);
104 OutsidePrescription($doc,$r,$pid,0);
106 if($res_presc<$GLOBALS['total_count'])
107 $uploaded_med_arr =PatientMedication($doc,$r,$pid,$med_limit);
109 $xml = $doc->saveXML();
110 $xml = preg_replace('/"/',"'",$xml);
111 //echo $xml."<br><br>";
112 $xml = stripStrings($xml,array('
'=>'','\t'=>''));
113 //$xml = stripStrings($xml,array('
'=>'','\t'=>'','\r'=>'','\n'=>''));
115 echo "<b>".htmlspecialchars( xl("Warning:"), ENT_NOQUOTES
)."</b><br><br>";
116 echo $dem_check."<br>";
117 echo htmlspecialchars( xl("The page will be redirected to Demographics. You can edit the country field and clickthrough to NewCrop again."), ENT_NOQUOTES
);
120 <script type
="text/javascript">
121 window
.setTimeout(function nav(){
122 window
.location
="patient_file/summary/demographics_full.php";
130 echo htmlspecialchars( xl('The following fields have to be filled to send request.'), ENT_NOQUOTES
);
137 echo "<font style='font-weight:bold;font-size:15px'>".htmlspecialchars( xl("Warning : "), ENT_NOQUOTES
)."</font><br>".$warning_msg;
138 echo "<br><b>".htmlspecialchars( xl('This will not prevent you from going to the e-Prescriptions site.'), ENT_NOQUOTES
)."</b>";
141 //################################################
142 //XML GENERATED BY OPENEMR
143 //################################################
144 //$fh=fopen('click_xml.txt','a');
148 //################################################
149 if(!extension_loaded('curl'))
151 echo htmlspecialchars( xl('PHP CURL module should be enabled in your server.'), ENT_NOQUOTES
);die;
153 $error = checkError($xml);
156 if($page=='compose'){
157 sqlQuery("update patient_data set soap_import_status=1 where pid=?",array($pid));
159 elseif($page=='medentry'){
160 sqlQuery("update patient_data set soap_import_status=3 where pid=?",array($pid));
162 foreach($allergy as $allId)
164 sqlQuery("update lists set erx_uploaded='1' where type='allergy' and pid=? and id=?",array($pid,$allId));
166 $prescArr=explode(':',$prescIds);
167 foreach($prescArr as $prescid)
169 sqlQuery("update prescriptions set erx_uploaded='1' ,active='0' where patient_id=? and id=?",array($pid,$prescid));
171 foreach($uploaded_med_arr as $value)
173 sqlQuery("update lists set erx_uploaded='1' where id=?",array($value));
174 //sqlQuery("update lists set enddate=".date('Y-m-d')." where
175 //(enddate is null or enddate = '' ) and id=? ",array($value));
178 <script language
='JavaScript'>
179 <?php
require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
181 <form name
='info' method
='post' action
="<?php echo getErxPath()?>" onsubmit
='return top.restoreSession()'>
182 <input type
='submit' style
='display:none'>
183 <input type
='hidden' id
='RxInput' name
='RxInput' value
="<?php echo $xml;?>">
185 <script type
="text/javascript" src
="../library/js/jquery.1.3.2.js"></script
>
186 <script type
='text/javascript'>
187 document
.forms
[0].submit();
193 echo htmlspecialchars( xl('NewCrop call failed', ENT_NOQUOTES
));