Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Quest Lab Hub module support #6941

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions interface/forms/procedure_order/common.php
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;
adunsulag marked this conversation as resolved.
Show resolved Hide resolved

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
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
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