quick minor path updates (#1968)
[openemr.git] / interface / weno / formularyUpdate.php
blobec76fb311c4e34a567bcb4dfca382eedb2cef6cf
1 <?php
2 /**
3 * weno admin.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Sherwin Gaddis <sherwingaddis@gmail.com>
8 * @copyright Copyright (c) 2016-2017 Sherwin Gaddis <sherwingaddis@gmail.com>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
11 require_once("../globals.php");
13 $zip = new ZipArchive;
14 $zip->open($GLOBALS['temporary_files_dir'].'/FormularyFiles.zip');
15 $zip->extractTo($GLOBALS['temporary_files_dir']);
16 $zip->close();
18 $file = "./Weno Exchange LLC/BSureFormulary.txt";
19 $lines = count(file($file));
20 echo text($lines). "<br>";
22 $i = 2;
23 do {
24 $fileName = new SplFileObject($file);
25 $fileName->seek($i);
26 echo text($fileName)."<br>"; //return the first line from file
28 $in = explode("|", $fileName);
30 echo text($in[2])."<br>";
31 echo text($in[5])."<br>";
32 echo text($in[8])."<br>";
34 $ndc = $in[2];
35 $price = $in[5];
36 $drugName = $in[8];
38 $find = sqlQuery("SELECT ndc FROM erx_drug_paid WHERE ndc = ?", array($ndc));
39 /**
40 * Insert drug if not found in the table
42 if (!empty($find['ndc'])) {
43 sqlStatementNoLog("INSERT INTO `erx_drug_paid` SET `drug_label_name` = ?, `NDC` = ?, `price_per_unit` = ? ", array($drugName,$ndc,$price));
44 echo xlt("Inserted")."<br> ";
45 } else {
46 /**
47 * If the drug is found update the price.
49 sqlStatementNoLog("UPDATE erx_drug_paid SET price_per_unit = ? WHERE ndc = ?", array($price, $ndc));
50 echo xlt("Updated!")."<br>";
52 $i++;
53 } while ($i < $lines);