Skip to content

Commit

Permalink
Quest Lab Hub module support (openemr#6941)
Browse files Browse the repository at this point in the history
* Quest Lab Hub module support

* PSR fixes

* fix dependency

* LabTransportEvent

* License change

* Event specified as Quest
  • Loading branch information
juggernautsei committed Nov 8, 2023
1 parent 403f7cf commit e308310
Show file tree
Hide file tree
Showing 5 changed files with 663 additions and 4 deletions.
18 changes: 18 additions & 0 deletions interface/forms/procedure_order/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@
use OpenEMR\Common\Csrf\CsrfUtils;
use OpenEMR\Common\Forms\ReasonStatusCodes;
use OpenEMR\Core\Header;
use OpenEMR\Events\Services\QuestLabTransmitEvent;
use Symfony\Component\EventDispatcher\EventDispatcher;

if (!$encounter) { // comes from globals.php
die("Internal error: we do not seem to be in an encounter!");
}
/**
* @var EventDispatcher
*/
$ed = $GLOBALS['kernel']->getEventDispatcher();

// Defaults for new orders.
$provider_id = getProviderIdOfEncounter($encounter);
Expand Down Expand Up @@ -408,6 +414,9 @@ function getListOptions($list_id, $fieldnames = array('option_id', 'title', 'seq
require_once(__DIR__ . "/../../procedure_tools/labcorp/ereq_form.php");
require_once(__DIR__ . "/../../procedure_tools/labcorp/gen_hl7_order.inc.php");
$alertmsg = gen_hl7_order($formid, $hl7, $reqStr);
} elseif ($gbl_lab === 'quest') {
require_once(__DIR__ . "/../../procedure_tools/quest/gen_hl7_order.inc.php");
$alertmsg = gen_hl7_order($formid, $hl7, $reqStr);
} else { // Default lab. Add more labs here.
require_once(__DIR__ . "/../../orders/gen_hl7_order.inc.php");
$alertmsg = gen_hl7_order($formid, $hl7);
Expand All @@ -427,6 +436,12 @@ function getListOptions($list_id, $fieldnames = array('option_id', 'title', 'seq
xlt("Order Successfully Sent") . "...\n" .
xlt("Order HL7 Content") .
":\n" . $hl7 . "\n";
if ($gbl_lab === 'quest') {
$order_log .= xlt("Transmitting order to Quest");
$ed->dispatch(new QuestLabTransmitEvent($hl7), QuestLabTransmitEvent::EVENT_LAB_TRANSMIT, 10);
$ed->dispatch(new QuestLabTransmitEvent($pid), QuestLabTransmitEvent::EVENT_LAB_POST_ORDER_LOAD, 10);
}

if ($_POST['form_order_psc']) {
if ($gbl_lab === 'labcorp') {
$order_log .= "\n" . date('Y-m-d H:i') . " " .
Expand Down Expand Up @@ -456,6 +471,7 @@ function getListOptions($list_id, $fieldnames = array('option_id', 'title', 'seq
file_put_contents($log_file, $order_log);
}
}

unset($_POST['bn_xmit']);
}
unset($_POST['bn_save']);
Expand Down Expand Up @@ -967,11 +983,13 @@ function createLabels(e) {
let acctid = <?php echo js_escape($gbl_client_acct); ?>;
let order = f.id.value;
let patient = <?php echo js_escape($patient['lname'] . ', ' . $patient['fname'] . ' ' . $patient['mname']); ?>;
let dob = <?php echo js_escape($patient['DOB']); ?>;
let pid = <?php echo js_escape($patient['pid']); ?>;
let url = top.webroot_url + "/interface/procedure_tools/libs/labs_ajax.php";
// this escapes above
let uri = "?action=print_labels&count=" + encodeURIComponent(count) + "&order=" + encodeURIComponent(order) + "&pid=" + encodeURIComponent(pid) +
"&acctid=" + encodeURIComponent(acctid) + "&patient=" + encodeURIComponent(patient) + "&specimen=" + encodeURIComponent(tarray) +
"&dob=" + encodeURIComponent(dob) +
"&csrf_token_form=" + <?php echo js_url(CsrfUtils::collectCsrfToken()); ?>;

// retrieve the labels
Expand Down
2 changes: 2 additions & 0 deletions interface/orders/gen_hl7_order.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,8 @@ function gen_hl7_order($orderid, &$out)
$setid = 0;
while ($pcrow = sqlFetchArray($pcres)) {
// Observation Request.

$dl = '';
$out .= "OBR" .
$d1 . ++$setid . // Set ID
$d1 . str_pad((string)$orderid, 4, "0", STR_PAD_LEFT) . // Placer Order Number
Expand Down
17 changes: 13 additions & 4 deletions interface/procedure_tools/libs/labs_ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
CsrfUtils::csrfNotVerified();
}

function orderDate($order)
{
$sql = "SELECT DATE_FORMAT(date_ordered, '%m/%d/%Y') AS date_ordered FROM procedure_order WHERE procedure_order_id = ? ";
return sqlQuery($sql, [$order]);
}

$action = $_GET['action'];

if ($action === 'code_detail') {
Expand Down Expand Up @@ -63,6 +69,8 @@
$specimen = array();
$specimens = explode(";", $_GET['specimen']);
$patient = strtoupper($_GET['patient']);
$order_date = orderDate($order);
$dob = $_GET['dob'];
$count = 1;
if ($_GET['count']) {
$count = (int)$_GET['count'];
Expand Down Expand Up @@ -96,13 +104,14 @@

$pdf->AddPage();
$barcode = '<div style="text-align: center;vertical-align: bottom;">';
$pdf->SetFont('', '', 7);
$pdf->writeCell(0, 3, 'CLIENT #: ' . $client, 0, 1, 'C');
$pdf->writeCell(0, 3, 'LAB REF #: ' . $ord, 0, 1, 'C');
$pdf->SetFont('', 'B', 8);
$pdf->writeCell(0, 3, $patient, 0, 1, 'C');
$pdf->SetFont('', '', 7);
$pdf->writeCell(0, 3, 'CLIENT#: ' . $client . '-WDL', 0, 1, 'C');
$pdf->writeCell(0, 3, 'DOS: ' . $order_date['date_ordered'], 0, 1, 'C');
$pdf->writeCell(0, 3, 'DOB: ' . $dob, 0, 1, 'C');
$code_info = $client . '-' . $ord;
$barcode .= '<barcode size=".8" pr=".4" code="' . attr($code_info) . '" type="C39" /></div>';
$barcode .= '<barcode size=".6" pr=".4" code="' . attr($code_info) . '" type="C39" /></div>';
$pdf->writeHTML($barcode);
}
$count--;
Expand Down
Loading

0 comments on commit e308310

Please sign in to comment.