Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weno eRx fixes #1139

Merged
merged 3 commits into from
Oct 22, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
458 changes: 229 additions & 229 deletions contrib/weno/drugspaidinsert.sql

Large diffs are not rendered by default.

42 changes: 26 additions & 16 deletions interface/weno/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,21 @@
$tables = new AdminProperties();

?>
<html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
<title><?php print xlt("Weno Admin"); ?></title>
<?php Header::setupHeader(); ?>

</head>
<body class="body_top">
<div class="container">
<style>
.row.text-center > div {
display: inline-block;
float: none;
}
</style>
<body class="body_top text-center">
<div class="container center-block">
<?php

// check to make sure only administrators access this page.
Expand All @@ -39,8 +46,6 @@
print xlt("Weno Service is Enabled")."<br><br>";
}



$drugData = $tables->drugTableInfo();
if (!$drugData['ndc']) {
echo "<a href='drugPaidInsert.php' class='btn btn-default'>".xlt("Import Formularies")."</a> <br>".xlt("Be patient this may take a while");
Expand All @@ -50,26 +55,31 @@

?>

<h3><?php echo xlt("Select State to Import for Pharmacy"); ?></h3>
<h3><?php echo xlt("Select State and City to Import for Pharmacy"); ?></h3>

<form method="post" action="import_pharmacies.php" >
<div class="col-lg-2">
<?php echo generate_form_field(array('data_type'=>$GLOBALS['state_data_type'],'list_id'=>$GLOBALS['state_list'], 'field_id'=>'state'), ''); ?>
</div>
<form method="post" action="import_pharmacies.php" class="form-inline text-center">

<div class="row text-center">
<div class="form-group well col-lg-5 text-center">
<?php echo generate_form_field(array('data_type' => $GLOBALS['state_data_type'], 'list_id' => $GLOBALS['state_list'], 'field_id' => 'state'), ''); ?>
<input type="text" class="form-control" id="form_city" name="form_city" placeholder="Enter City"><br/><br/>
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xla() of 'Enter City'
(I finally found one :) )

<button type="submit" class="btn btn-default n-save" value=><?php echo xlt("Import Pharmacies"); ?></button>
<h4><?php echo xlt("Be patient, this can take a while."); ?></h4>
</div>
</div>

<button type="submit" class="btn btn-default btn-save" value= ><?php echo xlt("Import Pharmacies"); ?></button>

<br>
<p><?php echo xlt("Be patient, this can take a while."); ?></p>
</form>
</form>
<br><br>

<?php if (!empty($finish)) {
echo $finish . xlt("with import");
} ?>


</div>
<script>
$(document).ready(function(){
$("#addtolistid_state").hide();
});
</script>
</body>
</html>
70 changes: 41 additions & 29 deletions interface/weno/confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function getReturnJson(x){
//this is to create the json script to be transmitted
$.ajax({
//feeds the json generator
url: 'jsonscript.php?getJson='+pharm_Id+','+value,
url: 'jsonScript.php?getJson='+pharm_Id+','+value,

success: function(response){
console.log(response);
Expand All @@ -157,40 +157,52 @@ function getReturnJson(x){
}); //end of confirm button

//Transmit order(s)
$('#order').click(function(){

$('#order').click(function() {
$('#success').html("<i class='fa fa-refresh fa-spin fa-3x fa-fw'></i>");

$.each(jsonArray, function(index, value){

$.ajax({
type: 'POST',
dataType: 'JSON',
url: 'https://apa.openmedpractice.com/apa/interface/weno/receivingrx.php?',
data: {"scripts": value},

success: function(response){
console.log(response);

$('#success').html('<p>'+response+'</p>');

},
error: function(xhr, status, error){
console.log(xhr);
console.log(status);
console.log(error);
console.warn(xhr.responseText);
}
}); //end of ajax call
var request = [];
var responses = [];
// Lets not talk to user here because most likely won't make to user anyway.
// So we'll batch the ajax calls with an apply and promise so everyone is happy.
// This isn't foolproof so look here if not batching large json requests.
$.each(jsonArray, function(index, value) {
request.push(
$.ajax({
type: 'POST',
dataType: 'JSON',
url: 'https://apa.openmedpractice.com/apa/interface/weno/receivingrx.php?',
data: {"scripts": value},

success: function (response) {
responses.push(response);
},
error: function (xhr, status, error) {
console.log(xhr);
console.log(status);
console.log(error);
console.warn(xhr.responseText);
}
}) //end of ajax push
);
}); // end of each loop

$("#transmit").toggle();
});
$("#transmit").toggle(); // turn off xmit button for spinner

// here we apply actual weno server requests and I've been promised
// a done event to present results to user in one shot.
$.when.apply(null, request).done(function() {
// all done with our requests, lets announce what weno says.
var announce = '<?php echo xlt("Send Complete - Prescription(s) Return Status");?>';
$('#success').html('<p><h4 class="bg-info">' + announce + '</h4></p>');
$.each(responses, function (index, response) {
console.log('result: ' + response);
$('#success').append('<p>' + response + '</p>');
});
});

}); // That's it for click event.

}); //end of doc ready


</script>
<br>
<br>
Expand All @@ -200,4 +212,4 @@ function getReturnJson(x){
<p><?php print xlt("Open Med Practice and its suppliers use their commercially reasonable efforts to provide the most current and complete data available to them concerning prescription histories, drug interactions and formularies, patient allergies and other factors, but by your use of this service you acknowledge that (1) the completeness and accuracy of such data depends upon the completeness and accuracy with which it is entered into connected electronic databases by physicians, physician’s offices, pharmaceutical benefits managers, electronic medical records firms, and other network participants, (2) such data is subject to error or omission in input, storage or retrieval, transmission and display, technical disruption, power or service outages, or other interruptions in electronic communication, any or all of which may be beyond the control of Open Med Practice and its suppliers, and (3) some information may be unavailable due to regulatory, contractual, privacy or other legal restrictions. You are responsible to use your clinical judgment at all times in rendering medical service and advice."); ?></p>
</footer>
</body>
</html>
</html>
3 changes: 3 additions & 0 deletions interface/weno/drugPaidInsert.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
sqlStatementNoLog("START TRANSACTION");

foreach ($drugsArray as $drug) {
if (empty($drug)) {
continue;
}
sqlStatementNoLog($drug);
}

Expand Down
63 changes: 38 additions & 25 deletions interface/weno/import_pharmacies.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,70 +15,83 @@


$state = filter_input(INPUT_POST, "form_state"); //stores the variable sent in the post

$srchCity = filter_input(INPUT_POST, "form_city");
$ref = $_SERVER["HTTP_REFERER"]; //stores the url the post came from to redirect back to

$sql = "SELECT MAX(id) FROM pharmacies"; // Find last record in the table
$getMaxId = sqlQuery($sql); //load to variable


$id = ++$getMaxId['MAX(id)']; // set start import ID to max id plus 1

/*
* Opens the CSV file and reads each line
*/
$file = fopen("../../contrib/weno/pharmacyList.csv", "r");
$path = '../../contrib/weno/pharmacyList.csv';
$entrys = new SplFileObject($path);
$entrys->setFlags(SplFileObject::READ_CSV);

while (! feof($file)) { //This loop continues till the end of the file is reached.
$line = fgets($file);
$entry = explode(",", $line);
$tm = 1;
//check entry 7 to match state
if ($entry[7] == $state) { //In the next iteration this needs to be gotten from the globals
++$id; //increment id once inside the loop
sqlStatementNoLog("SET autocommit=0");
sqlStatementNoLog("START TRANSACTION"); // Just in case someone else is adding.

$phone = str_replace(" ", "-", $entry[10]); //reformat the phone numbers and fax number
$fax = str_replace(" ", "-", $entry[11]);
$tm = 1; // Let's count how many.
foreach ($entrys as $entry) {//This loop continues till the end of the last line is reached.

//check entry 7 to match state
if (strtoupper($entry[7]) == strtoupper($state) && strtoupper($entry[6]) == strtoupper($srchCity)) { //In the next iteration this needs to be gotten from the globals

/*
* check the name is in the table
* if it is skip to the next name on the list
*/

$sql = "SELECT id FROM pharmacies WHERE name = ?";
$getNameId = sqlQuery($sql, array($entry[3]));
$sql = "SELECT id FROM pharmacies WHERE name = ? And npi = ?";
$getNameId = sqlQuery($sql, array($entry[3], $entry[2]));

if (empty($getNameId)) {
$phone = str_replace(" ", "-", $entry[10]); //reformat the phone numbers and fax number
$fax = str_replace(" ", "-", $entry[11]);
if (strlen($phone) == 10) { // Not Formatted
$phone = preg_replace("/([0-9]{3})([0-9]{3})([0-9]{4})/", "$1-$2-$3", $phone);
}
if (strlen($fax) == 10) {
$fax = preg_replace("/([0-9]{3})([0-9]{3})([0-9]{4})/", "$1-$2-$3", $fax);
}

$sql = "SELECT MAX(id) as id FROM pharmacies"; // Find last record in the table
$getMaxId = sqlQuery($sql); //load to variable
$id = $getMaxId['id'] + 1; // set start import ID to max id plus 1
$sql = "INSERT INTO pharmacies (id, name, transmit_method, email, ncpdp, npi) VALUES (?,?,?,?,?,?)";
$newInsert = array($id, $entry[3], 1, null, $entry[1], $entry[2]);
sqlStatement($sql, $newInsert);

// Add Address
$sql = "SELECT MAX(id) as id FROM addresses"; // Let's do this for case others insert addresses besides pharmacies.
$aid = sqlQuery($sql);
$aid = $aid['id'] + 1; // ++ with arrays can be troublesome..
//Insert Address into address table
$fid = $id; // Set the foreign_id to the id in the pharmacies table.
$aid = ++$id; // Set the address record to plus one
$asql = "INSERT INTO addresses (`id`, `line1`, `line2`, `city`, `state`, `zip`, `plus_four`, `country`, `foreign_id`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
$addressInsert = array($aid, $entry[4], $entry[5], $entry[6], $entry[7], $entry[8], '','USA', $fid);
sqlStatement($asql, $addressInsert);

//Insert Phone and Fax number
//Insert Phone and Fax number
$exPhone = explode("-", $phone);
$exFax = explode("-", $fax);

$sql = "SELECT MAX(id) as id FROM phone_numbers"; // Let's do this for the case others insert numbers besides pharmacies.
$aid = sqlQuery($sql);
$aid = $aid['id'] + 1;
$psql = "INSERT INTO phone_numbers (id, country_code, area_code, prefix, number, type, foreign_id) VALUES (?,?,?,?,?,?,?)";
$phoneInsert = array($aid, 1, $exPhone[0], $exPhone[1], $exPhone[2], 2, $fid);
sqlStatement($psql, $phoneInsert);
++$aid;
$faxInsert = array($aid, 1, $exFax[0], $exFax[1], $exFax[2], 5, $fid);
sqlStatement($psql, $faxInsert);

$tm++;
} //data insert if not present
} //loop conditional
} //end of loop

fclose($file);
sqlStatementNoLog("COMMIT"); // What else!
sqlStatementNoLog("SET autocommit=1");

header("Location: ". $ref."?status=finished");
header("Location: ". $ref."?status=finished");

?>
<i class="fa fa-refresh fa-spin fa-3x fa-fw"></i>
<span class="sr-only"><?php echo xlt("Loading... Please wait"); ?></span>
<span class="sr-only"><?php echo xlt("Loading... Please wait"); ?></span>
9 changes: 5 additions & 4 deletions interface/weno/jsonScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"fname" => $pInfo['fname'],
"street" => $pInfo['street'],
"city" => $pInfo['city'],
"state" => $pInfo['state'],
"postal" => $pInfo['postal_code'],
"DOB" => $pInfo['DOB'],
"Sex" => $sex
Expand All @@ -69,17 +70,17 @@
"provlname" => $proData[0]['fname'],
"provfname" => $proData[0]['lname'],
"provnpi" => $proData[0]['npi'],
"facilityfax" => str_replace("-", "", $proData[0]['fax']),
"facilityphone" => str_replace("-", "", $proData[0]['phone']),
"facilityfax" => preg_replace("/[^0-9]/", "", $proData[0]['fax']),
"facilityphone" => preg_replace("/[^0-9]/", "", $proData[0]['phone']),
"facilityname" => $proData[0]['name'],
"facilitystreet" => $proData[0]['street'],
"facilitycity" => $proData[0]['city'],
"facilitystate" => $proData[0]['state'],
"facilityzip" => $proData[0]['postal_code'],
"qualifier" => $proData[0]['weno_prov_id'],
"qualifier" => $GLOBALS['weno_provider_id'] . ':' . $proData[0]['weno_prov_id'],
"wenoAccountId" => $GLOBALS['weno_account_id'],
"wenoAccountPass" => $GLOBALS['weno_account_pass'],
"wenoClinicId" => $proData[0]['weno_prov_id']
"wenoClinicId" => $GLOBALS['weno_provider_id'] . ':' . $proData[0]['weno_prov_id']
)
),
array(
Expand Down
30 changes: 19 additions & 11 deletions interface/weno/markTx.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,33 @@
require_once("../globals.php");
$date = date("Y-m-d");
$script = filter_input(INPUT_GET, "rx");
$boxState = filter_input(INPUT_GET, "state");

$e_script = explode("-", $script);

if ($e_script[0] === "NewRx") {
//See if the value is set
$check = "SELECT ntx FROM prescriptions WHERE id = ?";
$getVal = sqlQuery($check, array($e_script[1]));
//See if the value is set Note patched out sjp I see no reason to check, just set it.
//$check = "SELECT ntx FROM prescriptions WHERE id = ?";
//$getVal = sqlQuery($check, array($e_script[1]));

//If the value is not set to 1 then set it for new rx to transmit
// ToDo add transmit date
if (empty($getVal['ntx'])) {
$sql = "UPDATE prescriptions SET ntx = '1', txDate = ? WHERE id = ?";
sqlStatement($sql, array($date, $e_script[1]));
//Set for new rx to transmit or reset if not, depends if selected.
if ($boxState) {
$sql = "UPDATE prescriptions SET ntx = ?, txDate = ? WHERE id = ?";
sqlStatement($sql, array($boxState, $date, $e_script[1]));
} else {
$sql = "UPDATE prescriptions SET ntx = ? WHERE id = ?";
sqlStatement($sql, array($boxState, $e_script[1]));
}
}
//There is a flaw in the logic because if the doc goes back in to edit the script this date gets wiped out.
if ($e_script[0] === "RefillRx") {
$sql = "UPDATE prescriptions SET txDate = ? WHERE id = ?";
sqlStatement($sql, array($date, $e_script[1]));
if ($e_script[0] === "RefillRx") { // Not sure I see reason this is needed Only worry if to xmit or not! - sjp
if ($boxState) {
$sql = "UPDATE prescriptions SET ntx = ?, txDate = ? WHERE id = ?";
sqlStatement($sql, array($boxState, $date, $e_script[1]));
} else {
$sql = "UPDATE prescriptions SET ntx = ? WHERE id = ?";
sqlStatement($sql, array($boxState, $e_script[1]));
}
}

if ($_GET['arr']) {
Expand Down
11 changes: 10 additions & 1 deletion library/classes/Prescription.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ function set_drug($drug)
{
if ($GLOBALS['weno_rx_enable']) {
$drug = explode("-", $drug); //striping the price from the drug name.
$drug = $drug[0];
$drug = trim($drug[0]);
}
$this->drug = $drug;

Expand All @@ -606,6 +606,15 @@ function set_drug($drug)
}
function get_drug()
{
if ($GLOBALS['weno_rx_enable']) {
$drug = trim($this->drug);
$sql = "SELECT NDC FROM erx_drug_paid WHERE drug_label_name LIKE ? ";
$val = array('%'.$drug.'%');
$ndc = sqlQuery($sql, $val);
$drug_id = $ndc['NDC'];
//Save this drug id
$this->drug_id = $drug_id;
}
return $this->drug;
}
function set_ntx($ntx)
Expand Down