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");
16 require_once("$srcdir/patient.inc");
18 use OpenEMR\Common\Csrf\CsrfUtils
;
19 use OpenEMR\Rx\Weno\TransmitData
;
20 use OpenEMR\Services\FacilityService
;
22 if (!CsrfUtils
::verifyCsrfToken($_GET["csrf_token_form"])) {
23 CsrfUtils
::csrfNotVerified();
26 $facilityService = new FacilityService();
27 $facility = $facilityService->getPrimaryBillingLocation();
29 $pid = $GLOBALS['pid'];
30 $uid = $_SESSION['authUserID'];
32 $validation = new TransmitData();
34 $patient = $validation->validatePatient($pid);
35 $pharmacy = $validation->patientPharmacyInfo($pid);
37 if (empty($facility['name']) ||
$facility['name'] == "Your clinic name here") {
38 print xlt("Please fill out facility name properly");
42 if (empty($facility['phone'])) {
43 print xlt("Please fill out facility phone properly");
47 if (empty($facility['fax'])) {
48 print xlt("Please fill out facility fax properly");
52 if (empty($facility['street'])) {
53 print xlt("Please fill out facility street properly");
57 if (empty($facility['city'])) {
58 print xlt("Please fill out facility city properly");
62 if (empty($facility['state'])) {
63 print xlt("Please fill out facility state properly");
67 if (empty($facility['postal_code'])) {
68 print xlt("Please fill out facility postal code properly");
72 if (empty($GLOBALS['weno_account_id'])) {
73 print xlt("Weno Account ID information missing")."<br>";
76 if (empty($GLOBALS['weno_provider_id'])) {
77 print xlt("Weno Account Clinic ID information missing")."<br>";
80 if (empty($patient['DOB'])) {
81 print xlt("Patient DOB missing"). "<br>";
84 if (empty($patient['street'])) {
85 print xlt("Patient street missing"). "<br>";
88 if (empty($patient['postal_code'])) {
89 print xlt("Patient Zip Code missing"). "<br>";
92 if (empty($patient['city'])) {
93 print xlt("Patient city missing"). "<br>";
96 if (empty($patient['state'])) {
97 print xlt("Patient state missing"). "<br>";
100 if (empty($patient['sex'])) {
101 print xlt("Patient sex missing"). "<br>";
104 if (empty($pharmacy['name'])) {
105 print xlt("Pharmacy not assigned to the patient"). "<br>";
108 $ncpdpLength = strlen($pharmacy['ncpdp']);
109 if (empty($pharmacy['ncpdp']) ||
$ncpdpLength < 7) {
110 print xlt("Pharmacy missing NCPDP ID or less than 7 digits"). "<br>";
113 $npiLength = strlen($pharmacy['npi']);
114 if (empty($pharmacy['npi'] ||
$npiLength < 10)) {
115 print xlt("Pharmacy missing NPI or less than 10 digits"). "<br>";
119 //Test if the NPI is a valid number on file
120 $seekvalidation = $validation->validateNPI($pharmacy['npi']);
121 if ($seekvalidation == 0) {
122 print xlt("Please use valid NPI");
125 header('Location: confirm.php');