Skip to content

Commit

Permalink
weno updates (openemr#4360)
Browse files Browse the repository at this point in the history
  • Loading branch information
juggernautsei committed May 8, 2021
1 parent 2e1087e commit 72174c7
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 67 deletions.
11 changes: 0 additions & 11 deletions interface/weno/facilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,7 @@
</table>
<input type="<?php echo xla('Submit'); ?>" value="update" id="save_weno_id" class="btn_primary">
</form>

<div style="padding-top: 20px">
<h3><?php echo xlt('Import/Update Pharmacies') ?></h3>
<div id="importstatus" style="padding-top: 15px">
<button class="btn btn-primary" id="connected" title="<?php echo xla("Weno Connected Phamacies Only");?>">
<i id="loading" class="fa fa-sync fa-spin hide"></i><?php echo xlt('Import/Update')?></button>
</div>
</div>

</div>
<script src="weno.js"></script>
</body>
</html>


10 changes: 6 additions & 4 deletions interface/weno/rxlogmanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
use OpenEMR\Common\Acl\AclMain;
use OpenEMR\Rx\Weno\Container;

//ensure user has proper access
if (!AclMain::aclCheckCore('admin', 'super')) {
echo xlt('ACL Administration Not Authorized');
/*
* access control is on Weno side based on the user login
*/
if (!AclMain::aclCheckCore('patient', 'med')) {
echo xlt('Prescriptions Review Not Authorized');
exit;
}

Expand All @@ -30,7 +32,7 @@
exit;
}

$url = "https://test.wenoexchange.com/en/EPCS/RxLog?useremail=";
$url = "https://online.wenoexchange.com/en/EPCS/RxLog?useremail=";

//**warning** do not add urlencode to $provider_info['email']
$urlOut = $url . $provider_info['email'] . "&data=" . urlencode($logurlparam);
Expand Down
7 changes: 4 additions & 3 deletions interface/weno/wenoconnected.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
use OpenEMR\Rx\Weno\wenoPharmaciesImport;

//ensure user has proper access
if (!AclMain::aclCheckCore('admin', 'super')) {
echo xlt('ACL Administration Not Authorized');
if (!AclMain::aclCheckCore('patient', 'med')) {
echo xlt('Pharmacy Import not authorized');
exit;
}

//Weno has decided to not force the import of pharmacies since they are using the iframe
//and the pharmacy can be selected at the time of creating the prescription.
$phIN = new wenoPharmaciesImport();

$status = $phIN->importPharmacy();
Expand Down
6 changes: 3 additions & 3 deletions src/Rx/Weno/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct()
/**
* @return TransmitProperties
*/
public function getTransmitproperties()
public function getTransmitproperties(): TransmitProperties
{
if ($this->transmitproperties === null) {
$this->transmitproperties = new TransmitProperties();
Expand All @@ -40,7 +40,7 @@ public function getTransmitproperties()
/**
* @return LogProperties
*/
public function getLogproperties()
public function getLogproperties(): LogProperties
{
if ($this->logproperties === null) {
$this->logproperties = new LogProperties();
Expand All @@ -51,7 +51,7 @@ public function getLogproperties()
/**
* @return FacilityProperties
*/
public function getFacilityproperties()
public function getFacilityproperties(): FacilityProperties
{
if ($this->facilityproperties === null) {
$this->facilityproperties = new FacilityProperties();
Expand Down
91 changes: 45 additions & 46 deletions src/Rx/Weno/TransmitProperties.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class TransmitProperties
private $locid;
private $vitals;
private $subscriber;
private $pid;
private $ncpdp;
private $cryptoGen;

Expand Down Expand Up @@ -57,44 +56,48 @@ public function createJsonObject()
}
$gender = $this->patient['sex'];
$heighDate = explode(" ", $this->vitals['date']);
if ($this->subscriber == 'self') {
$relationship = 'Y';
} else {
$relationship = 'N';
}
$phoneprimary = str_replace("-", "", $this->patient['phone_cell']);
//create json array
$wenObj = [
'UserEmail' => $this->provider_email['email'],
'MD5Password' => md5($this->provider_pass),
"LocationID" => $this->locid['weno_id'],
"TestPatient" => $mode,
'PatientType' => 'Human',
'OrgPatientID' => $this->patient['pid'],
'LastName' => $this->patient['lname'],
'FirstName' => $this->patient['fname'],
'MiddleName' => $this->patient['mname'],
'Prefix' => 'NA',
'Suffix' => 'NA',
"Gender" => $gender[0],
"DateOfBirth" => $this->patient['dob'],
"AddressLine1" => $this->patient['street'],
"AddressLine2" => "NA",
"City" => $this->patient['city'],
"State" => $this->patient['state'],
"PostalCode" => $this->patient['postal_code'],
"CountryCode" => "US",
"PrimaryPhone" => $this->patient['phone_cell'],
"SupportsSMS" => "Y",
"PatientEmail" => $this->patient['email'],
"PatientHeight" => $this->vitals['height'],
"PatientWeight" => $this->vitals['weight'],
"HeightWeightObservationDate" => $heighDate[0],
"ResponsiblePartySameAsPatient" => 'Y',
"PatientLocation" => "Home",
"PrimaryPharmacyNCPCP" => $this->ncpdp,
"AlternativePharmacyNCPCP" => $this->ncpdp
];

$wenObj = [];
array_merge(
$wenObj,
$wenObj['UserEmail'] = $this->provider_email['email'],
$wenObj['MD5Password'] = md5($this->provider_pass),
$wenObj['LocationID'] = $this->locid['weno_id'],
$wenObj['TestPatient'] = $mode,
$wenObj['PatientType'] = 'Human',
$wenObj['OrgPatientID'] = $this->patient['pid'],
$wenObj['LastName'] = $this->patient['lname']
);
// optional fields (added only if they have a value)
//if (isset($this->patient['mname'])) {
// array_merge($wenObj, $wenObj['MiddleName'] = $this->patient['mname']);
//};
array_merge(
$wenObj,
$wenObj['FirstName'] = $this->patient['fname'],
$wenObj['Gender'] = $gender[0],
$wenObj['DateOfBirth'] = $this->patient['dob'],
$wenObj['AddressLine1'] = $this->patient['street'],
$wenObj['City'] = $this->patient['city'],
$wenObj['State'] = $this->patient['state'],
$wenObj['PostalCode'] = $this->patient['postal_code'],
$wenObj['CountryCode'] = "US",
$wenObj['PrimaryPhone'] = $phoneprimary,
$wenObj['SupportsSMS'] = 'Y'
);
// optional fields (added only if they have a value)
if (isset($this->patient['email'])) {
array_merge($wenObj, $wenObj['PatientEmail'] = $this->patient['email']);
};
array_merge(
$wenObj,
$wenObj['PatientHeight'] = substr($this->vitals['height'], 0, -3),
$wenObj['PatientWeight'] = substr($this->vitals['weight'], 0, -3),
$wenObj['HeightWeightObservationDate'] = $heighDate[0],
$wenObj["ResponsiblePartySameAsPatient"] = 'Y',
$wenObj['PatientLocation'] = "Home",
);
return json_encode($wenObj);
}

Expand All @@ -105,7 +108,7 @@ public function getProviderEmail()
{
$provider_info = sqlQuery("select email from users where username=? ", [$_SESSION["authUser"]]);
if (empty($provider_info['email'])) {
echo xlt('Provider email address is missing');
echo xlt('Provider email address is missing. Go to address book to add providers email address');
exit;
} else {
return $provider_info;
Expand Down Expand Up @@ -142,7 +145,7 @@ private function getPatientInfo()
//Since the transmitproperties is called in the logproperties
//need to check to see if in an encounter or not. Patient data is not required to view the Weno log
if (empty($_SESSION['encounter'])) {
return ;
die("please select an encounter");
}
$missing = 0;
$patient = sqlQuery("select title, fname, lname, mname, street, state, city, email, phone_cell, postal_code, dob, sex, pid from patient_data where pid=?", [$_SESSION['pid']]);
Expand Down Expand Up @@ -170,12 +173,8 @@ private function getPatientInfo()
echo xlt("Street Address incomplete Missing") . "<br>";
++$missing;
}
if (empty($patient['email'])) {
echo xlt("Email Address Missing") . "<br>";
++$missing;
}
if ($missing > 0) {
exit;
die('Pleasae add the missing data and try again');
}
return $patient;
}
Expand All @@ -190,7 +189,7 @@ public function cipherpayload()
$enc_key = $this->cryptoGen->decryptStandard($GLOBALS['weno_encryption_key']);
if ($enc_key) {
$key = substr(hash('sha256', $enc_key, true), 0, 32);
$iv = chr(0x1) . chr(0x2) . chr(0x3) . chr(0x5) . chr(0x7) . chr(0x9) . chr(0x0) . chr(0x1) . chr(0x2) . chr(0x3) . chr(0x5) . chr(0x7) . chr(0x9) . chr(0x0) . chr(0x1) . chr(0x2);
$iv = chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0);
$ciphertext = base64_encode(openssl_encrypt($this->payload, $cipher, $key, OPENSSL_RAW_DATA, $iv));
return $ciphertext;
} else {
Expand Down

0 comments on commit 72174c7

Please sign in to comment.