Fully responsive globals.php with vertical menu (#2460)
[openemr.git] / interface / weno / validate.php
blob965c45678721fa587cae3e7b240af27d8ac55f1b
1 <?php
2 /**
3 * weno rx validation.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Sherwin Gaddis <sherwingaddis@gmail.com>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2016-2017 Sherwin Gaddis <sherwingaddis@gmail.com>
10 * @copyright Copyright (c) 2017-2018 Brady Miller <brady.g.miller@gmail.com>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once('../globals.php');
17 use OpenEMR\Rx\Weno\TransmitData;
19 if (!verifyCsrfToken($_GET["csrf_token_form"])) {
20 csrfNotVerified();
24 $pid = $GLOBALS['pid'];
25 $uid = $_SESSION['authUserID'];
27 $validation = new TransmitData();
29 $patient = $validation->validatePatient($pid);
30 $pharmacy = $validation->patientPharmacyInfo($pid);
32 if (empty($GLOBALS['weno_account_id'])) {
33 print xlt("Weno Account ID information missing")."<br>";
34 exit;
36 if (empty($GLOBALS['weno_provider_id'])) {
37 print xlt("Weno Account Clinic ID information missing")."<br>";
38 exit;
40 if (empty($patient['DOB'])) {
41 print xlt("Patient DOB missing"). "<br>";
42 exit;
44 if (empty($patient['street'])) {
45 print xlt("Patient street missing"). "<br>";
46 exit;
48 if (empty($patient['postal_code'])) {
49 print xlt("Patient Zip Code missing"). "<br>";
50 exit;
52 if (empty($patient['city'])) {
53 print xlt("Patient city missing"). "<br>";
54 exit;
56 if (empty($patient['state'])) {
57 print xlt("Patient state missing"). "<br>";
58 exit;
60 if (empty($patient['sex'])) {
61 print xlt("Patient sex missing"). "<br>";
62 exit;
64 if (empty($pharmacy['name'])) {
65 print xlt("Pharmacy not assigned to the patient"). "<br>";
66 exit;
68 $ncpdpLength = strlen($pharmacy['ncpdp']);
69 if (empty($pharmacy['ncpdp']) || $ncpdpLength < 10) {
70 print xlt("Pharmacy missing NCPDP ID or less than 10 digits"). "<br>";
71 exit;
73 $npiLength = strlen($pharmacy['npi']);
74 if (empty($pharmacy['npi'] || $npiLength < 7)) {
75 print xlt("Pharmacy missing NPI or less than 7 digits"). "<br>";
76 exit;
78 //validate NPI exist
79 //Test if the NPI is a valid number on file
80 $seekvalidation = $validation->validateNPI($pharmacy['npi']);
81 if ($seekvalidation == 0) {
82 print xlt("Please use valid NPI");
83 exit;
85 header('Location: confirm.php');